Skip to main content
deleted 78 characters in body
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203

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

In python it's just:

#gdal# 1.xGDAL 2+
ds = ogrgdal.OpenOpenEx('some geojson string')

or

#gdal

# 2GDAL 1.x11
ds = gdalogr.OpenExOpen('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)

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)

You pass the geojson string directly to the gdal OpenEx function.

In python it's just:

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


# GDAL 1.11
ds = ogr.Open('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)
deleted 43 characters in body; deleted 1 character in body; deleted 1 character in body; deleted 6 characters in body
Source Link
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)
feature.GetGeometryRef().ExportToWkt()

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

Output:

GeoJSON
POINT (146.7 -41.9)

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)
feature.GetGeometryRef().ExportToWkt()

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

Output:

GeoJSON
POINT (146.7 -41.9)

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)
added 510 characters in body
Source Link
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)
feature.GetGeometryRef().ExportToWkt()

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

Output:

GeoJSON
POINT (146.7 -41.9)

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')

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)
feature.GetGeometryRef().ExportToWkt()

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

Output:

GeoJSON
POINT (146.7 -41.9)
added 9 characters in body; edited body
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203
Loading
added 8 characters in body
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203
Loading
added 6 characters in body
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203
Loading
deleted 1 character in body
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203
Loading
Source Link
user2856
  • 69.6k
  • 6
  • 119
  • 203
Loading