Skip to main content
Add example of how GDAL reads ESRI JSON
Source Link
user30184
  • 69.1k
  • 4
  • 71
  • 125

Despite the problem with multilinestrings GDAL seems to read ESRI JSON quite well. Test with the following JSON

{
 "displayFieldName": "roadnamestring",
 "fieldAliases": {
  "functionhierarchy": "FunctionHierarchy",
  "OBJECTID": "OBJECTID",
  "roadontype": "RoadOnType",
  "roadnamestring": "roadnamestring",
  "shape_Length": "shape_Length"
 },
 "geometryType": "esriGeometryPolyline",
 "spatialReference": {
  "wkid": 3857,
  "latestWkid": 3857
 },
 "fields": [
  {
   "name": "functionhierarchy",
   "type": "esriFieldTypeSmallInteger",
   "alias": "FunctionHierarchy"
  },
  {
   "name": "OBJECTID",
   "type": "esriFieldTypeOID",
   "alias": "OBJECTID"
  },
  {
   "name": "roadontype",
   "type": "esriFieldTypeSmallInteger",
   "alias": "RoadOnType"
  },
  {
   "name": "roadnamestring",
   "type": "esriFieldTypeString",
   "alias": "roadnamestring",
   "length": 80
  },
  {
   "name": "shape_Length",
   "type": "esriFieldTypeDouble",
   "alias": "shape_Length"
  }
 ],
 "features": [
  {
   "attributes": {
    "functionhierarchy": 4,
    "OBJECTID": 2857,
    "roadontype": 1,
    "roadnamestring": "ALPINE WAY",
    "shape_Length": 121053.94010502081
   },
   "geometry": {
    "paths": [
     [
      [
       16490352.71125,
       -4374934.9532499984
      ],
      [
       16490354.657125004,
       -4374949.0618750006
      ],
      [
       16490364.728625,
       -4374975.3704999983
      ],
      [
       16490377.779749997,
       -4374991.6128749996
      ],
      [
       16490395.435874999,
       -4375003.0787499994
      ],
      [
       16490411.941624999,
       -4375010.7230000012
      ]
           ]
          ]
         }
        }
       ]
}

Ogrinfo finds the SRS and attributes:

ogrinfo esritest.json -al -so
INFO: Open of `esritest.json'
      using driver `GeoJSON' successful.

Layer name: OGRGeoJSON
Geometry: Line String
Feature Count: 1
Extent: (16490352.711250, -4375010.723000) - (16490411.941625, -4374934.953250)
Layer SRS WKT:
PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +
x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
    AUTHORITY["EPSG","3857"]]
FID Column = OBJECTID
functionhierarchy: Integer (0.0)
OBJECTID: Integer (0.0)
roadontype: Integer (0.0)
roadnamestring: String (80.0)
shape_Length: Real (0.0)

Despite the problem with multilinestrings GDAL seems to read ESRI JSON quite well. Test with the following JSON

{
 "displayFieldName": "roadnamestring",
 "fieldAliases": {
  "functionhierarchy": "FunctionHierarchy",
  "OBJECTID": "OBJECTID",
  "roadontype": "RoadOnType",
  "roadnamestring": "roadnamestring",
  "shape_Length": "shape_Length"
 },
 "geometryType": "esriGeometryPolyline",
 "spatialReference": {
  "wkid": 3857,
  "latestWkid": 3857
 },
 "fields": [
  {
   "name": "functionhierarchy",
   "type": "esriFieldTypeSmallInteger",
   "alias": "FunctionHierarchy"
  },
  {
   "name": "OBJECTID",
   "type": "esriFieldTypeOID",
   "alias": "OBJECTID"
  },
  {
   "name": "roadontype",
   "type": "esriFieldTypeSmallInteger",
   "alias": "RoadOnType"
  },
  {
   "name": "roadnamestring",
   "type": "esriFieldTypeString",
   "alias": "roadnamestring",
   "length": 80
  },
  {
   "name": "shape_Length",
   "type": "esriFieldTypeDouble",
   "alias": "shape_Length"
  }
 ],
 "features": [
  {
   "attributes": {
    "functionhierarchy": 4,
    "OBJECTID": 2857,
    "roadontype": 1,
    "roadnamestring": "ALPINE WAY",
    "shape_Length": 121053.94010502081
   },
   "geometry": {
    "paths": [
     [
      [
       16490352.71125,
       -4374934.9532499984
      ],
      [
       16490354.657125004,
       -4374949.0618750006
      ],
      [
       16490364.728625,
       -4374975.3704999983
      ],
      [
       16490377.779749997,
       -4374991.6128749996
      ],
      [
       16490395.435874999,
       -4375003.0787499994
      ],
      [
       16490411.941624999,
       -4375010.7230000012
      ]
           ]
          ]
         }
        }
       ]
}

Ogrinfo finds the SRS and attributes:

ogrinfo esritest.json -al -so
INFO: Open of `esritest.json'
      using driver `GeoJSON' successful.

Layer name: OGRGeoJSON
Geometry: Line String
Feature Count: 1
Extent: (16490352.711250, -4375010.723000) - (16490411.941625, -4374934.953250)
Layer SRS WKT:
PROJCS["WGS 84 / Pseudo-Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +
x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],
    AUTHORITY["EPSG","3857"]]
FID Column = OBJECTID
functionhierarchy: Integer (0.0)
OBJECTID: Integer (0.0)
roadontype: Integer (0.0)
roadnamestring: String (80.0)
shape_Length: Real (0.0)
Source Link
user30184
  • 69.1k
  • 4
  • 71
  • 125

There was indeed a bug in reading ESRI JSON MultiLinestrings with GDAL. It has now corrected in GDAL trunk (version 2.2-dev) with changeset https://trac.osgeo.org/gdal/changeset/34773. No backports have been done to 1.11, 2.0, or 2.1 series.