Esri-JSON (Esri JavaScript Object Notation) Reader/Writer
Licensing options for this format begin with FME Professional Edition.
Esri-JSON is a standard for encoding spatial data in JSON structured text.
FME currently supports the Esri Feature Sets, as defined at http://resources.esri.com/help/9.3/BusinessAnalyst/Online_apis/apis/REST/types.html#FeatureSet
Overview
Esri-JSON encodes both geometry and feature information into objects. An Esri Feature Set is a collection of feature with the same geometry type and coordinate system. In a JSON document, a feature set is represented by JSON object. The JSON object has three keys:
- geometryType,
- spatialReference, and
- features.
The value of the geometryType key is a string which indicates the type of geometry contained by the features in the data set. Valid geometry types are points, polylines, polygons, envelopes and multi-points.
The value of the spatialReference key is a JSON object containing coordinate system data for the features in the data set. In ESRIJSON, coordinate systems are represented by their well known ID, typically an EPSG number. The spatialReference key and value are duplicated in the geometry object of each feature in the dataset. A spatial reference object representing the EPSG:4326 coordinate system is shown below.
{ “wkid“ : 4326 }
The value of the features key is an array of JSON objects, representing the individual features in the data set. Each feature object has two keys, geometry and attributes. The value of the attributes key is a JSON object whose keys and values represent feature attribute names and values. The value of the geometry key is an Esri-JSON geometry object. The various types of geometry objects are listed below.
Point
All point geometries are simple two dimensional geometry.
{“x”:-122.43, “y”:49.2, “spatialReference”:{“wkid”:4326}}
Polyline
A polyline is an array of linear segments. Each linear segment is an array of points. A point is represented as two element array. The first element is always the x-coordinate and the second is always the y-coordinate, regardless of the coordinate system being used.
{
“paths“:[
[ [166.4359,19.504367], [166.4699,19.509833], [166.5086,19.4887],
[166.50975,19.4668], [166.49335,19.4504], [166.4617,19.441],
[166.4277,19.452733], [166.4183,19.474633], [166.4359,19.504367]
] ],
“spatialReference“:{“wkid“:4326}
}
Polygon
Polygon geometries have similar structure to polylines. A polygon consists of an array of rings, each of which is an array of points. As with polylines, the first element in a point is always the x-coordinate, and the second is always the y-coordinate.
{
“rings“:[
[ [-62.22015,16.730367], [-62.2345,16.737367], [-62.2431,16.738],
[-62.25455,16.7361],[-62.26695,16.715733],[-62.26695,16.6839],
[-62.2555,16.6648],[-62.22685,16.659067],[-62.21155,16.664167],
[-62.20585,16.696633],[-62.22015,16.730367]
] ],
“spatialReference“:{“wkid“:4326}
}
Envelope
Envelope geometries are simply bounding box features, represented by two points.
{
“xmin“:166.4183, “ymin“:19.441, “xmax“:166.50975, “ymax“:19.509833,
“spatialReference“:{“wkid“:4326}
}
MultiPoint
Multipoint geometries are represented by an array of two dimensional points. As with other geometries, the first element in each point is the x-coordinate, and the second is the y-coordinate.
{
“points“:[
[105.68155,-10.381467], [105.65865,-10.3823],
[105.6382,-10.377333], [105.61965,-10.3699],
[105.619,-10.363733], [105.63325,-10.355033],
[105.6667,-10.351733], [105.68095,-10.3563],
[105.689,-10.3662], [105.69085,-10.376933],
[105.68155,-10.381467]
],
“spatialReference“:{“wkid“:4326}
}
Reader Overview
The Esri-JSON reader can read many different types of JSON text.
It may be used to read an Esri Feature Set object, as described in the Overview section above. It may also be used to read individual geometry objects, or an array of geometry objects. Finally, if the root JSON object or array in a dataset is not a known Esri-JSON object, the reader will examine each value in the object or array and attempt to use these values to create features.
Coordinate Systems
The ESRIJSON reader currently supports coordinate systems that have an EPSG number.
In a spatialReference JSON object, the reader will use the value of the wkid key as the EPSG coordinate system number. For example, if a dataset contains the following spatial reference, the coordinate system would be EPSG:4326.
{ “spatialReference”:{“wkid”:4326} }
Writer Overview
The Esri-JSON writer writes out a file for each feature type. Each file contains a single JSON object, whose RecordSet property contains an Esri-JSON FeatureSet object.
Coordinate Systems
Each feature type may have a unique coordinate system. The Esri-JSON writer will output the Esri well-known ID for the coordinate system, as the value of the spatialReference key in the top-level object.
In general, the well-known ID is an EPSG coordinate system number. If a well-known ID cannot be determined for a particular coordinate system, the coordinate system name will be output instead.
Geometry
FME feature geometry is written out in an Esri-JSON geometry object as the value of the geometry key in an ESRIJSON feature object. Because Esri-JSON only supports linear geometry, arcs will be stroked to lines, and ellipses will be stroked to polygons.
Features containing unsupported geometry will have a null value written to the geometry key.