[gdal-dev] ogr.VectorTranslate to json appears to be incomplete
Michael Smith
michael.smith.erdc at gmail.com
Fri May 26 06:12:47 PDT 2023
I assume I am doing something incorrect here but I am taking an incoming geojson feature and attempting to split it on the dateline:
Using gdal 3.7.0 from conda-forge
ds = gdal.OpenEx('{ "type": "Polygon", "coordinates": [ [ [ 179.828821134787177, 66.686572724877635 ], [ -179.718786846664386, 66.695039153881993 ], [ -179.699204739767083, 66.515803857102057 ], [ 179.851649370943306, 66.507409512673448 ], [ 179.828821134787177, 66.686572724877635 ] ] ] }')
gdal.VectorTranslate("/vsimem/out.json", ds, format="GeoJSON", layerCreationOptions=["RFC7946=YES", "WRAPDATELINE=YES", "WRITE_BBOX=YES"])
f = gdal.VSIFOpenL("/vsimem/out.json", "rb")
content = gdal.VSIFReadL(1, 10000, f).decode("UTF-8")
gdal.VSIFCloseL(f)
gdal.Unlink("/vsimem/out.json")
If I just do:
newds = ogr.Open(content)
I get RuntimeError: Failed to read GeoJSON data
It appears to be missing the closing “]}”.
If I do:
newds = ogr.Open(content+"]}")
Then it works fine.
--
Michael Smith
Remote Sensing/GIS Center
US Army Corps of Engineers
More information about the gdal-dev
mailing list