Skip to main content
7 of 8
deleted 43 characters in body; deleted 1 character in body; deleted 1 character in body; deleted 6 characters in body
user2856
  • 69.6k
  • 6
  • 119
  • 203

You pass the geojson string directly to the ogr Open/gdal OpenEx function.

In python it's just:

#gdal 1.x
ds = ogr.Open('some geojson string')

or

#gdal 2.x
ds = gdal.OpenEx('some geojson string')

An example to demonstrate:

from osgeo import gdal

geojson = '{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[146.7,-41.9]}}]}'
ds = gdal.OpenEx(geojson)
layer = ds.GetLayer()
feature = layer.GetFeature(0)

print(ds.GetDriver().ShortName)
print(feature.GetGeometryRef().ExportToWkt())

Output:

GeoJSON
POINT (146.7 -41.9)
user2856
  • 69.6k
  • 6
  • 119
  • 203