Convert GeoJSON to ArchGDAL geometry

Viewed 70

When I attempt to convert a GeoJSON to an ArchGDAL geometry like seen below, I end up with a NULL Geometry. How would one convert a String GeoJSON notation to a geometry object?

using ArchGDAL

test = """{ "type": "FeatureCollection",
  "features": [
    { "type": "Feature",
      "geometry": {"type": "Point", "coordinates": [102.0, 0.5]},
      "properties": {"prop0": "value0"}
    }
  ]
}"""

ArchGDAL.fromJSON(test)
# NULL Geometry
1 Answers

Turns out the GeoJSON can be read by simply using ArchGDAL.read(), (and, in this example extracting the first layer using ArchGDAL.getlayer())

ArchGDAL.getlayer(ArchGDAL.read(test), 0)
# Layer: OGRGeoJSON
#   Geometry 0 (): [wkbPoint], POINT (102.0 0.5)
#      Field 0 (prop0): [OFTString], value0
Related