JSON To Features (Conversion)

Summary

Converts feature collections in an Esri JSON formatted file (.json) or a GeoJSON formatted file (.geojson) to a feature class.

Usage

  • If the input .json file has the hasZ or hasM property set to True, the output features will have z- and m-values.

  • If the input is a .geojson file, you must select the geometry type to convert to a feature class. GeoJSON supports multiple feature types within the same file, and a feature class must be composed of features of the same feature type.

  • Text fields in the output have a long length (2 billion characters), as the JSON and GeoJSON format specifications do not include a length property for text attributes. To improve conversion performance, a large fixed length is used rather than reading all values to determine the largest number of characters.

  • The JSON and GeoJSON format specifications do not include a standard way to store datetime values. A datetime value may be represented as an integer value of seconds since the Unix time epoch. To convert this number to a datetime value, use the Calculate Field tool or a Python expression such as datetime.datetime.fromtimestamp(!date_field!).

  • When the input is a .geojson file, the attributes of the first record are used to define the schema of the output feature class.

Parameters

LabelExplanationData Type
Input JSON or GeoJSON

The input .json or .geojson file that will be converted to a feature class.

The input file extension determines the format used by the tool for proper conversion. For Esri JSON formatted file, use the .json extension; for GeoJSON formatted files, use the .geojson extension.

File
Output Feature Class

The output feature class that will contain the features from the input .json or .geojson file.

Feature Class
Geometry Type
(Optional)

Specifies the geometry type that will be used to convert from GeoJSON to features. This parameter is only used when the input is a .geojson file. If the .geojson file does not contain any of the specified geometry types, the output feature class will be empty.

  • PointPoints will be converted to features.
  • MultipointMultipoints will be converted to features.
  • PolylinePolylines will be converted to features.
  • PolygonPolygons will be converted to features.
String

arcpy.conversion.JSONToFeatures(in_json_file, out_features, {geometry_type})
NameExplanationData Type
in_json_file

The input .json or .geojson file that will be converted to a feature class.

The input file extension determines the format used by the tool for proper conversion. For Esri JSON formatted file, use the .json extension; for GeoJSON formatted files, use the .geojson extension.

File
out_features

The output feature class that will contain the features from the input .json or .geojson file.

Feature Class
geometry_type
(Optional)

Specifies the geometry type that will be used to convert from GeoJSON to features. This parameter is only used when the input is a .geojson file. If the .geojson file does not contain any of the specified geometry types, the output feature class will be empty.

  • POINTPoints will be converted to features.
  • MULTIPOINTMultipoints will be converted to features.
  • POLYLINEPolylines will be converted to features.
  • POLYGONPolygons will be converted to features.
String

Code sample

JSONToFeatures example (Python window)

The following Python script demonstrates how to use the JSONToFeatures function.

import arcpy
import os
arcpy.env.workspace = "c:/data"
arcpy.conversion.JSONToFeatures("myjsonfeatures.json", os.path.join("outgdb.gdb", "myfeatures"))

Related topics