When testing the following code:
from osgeo import gdal
import json
def read_file(filename):
f = gdal.VSIFOpenL(filename, "rb")
if f is None:
return None
content = gdal.VSIFReadL(1, 10000, f).decode('UTF-8')
gdal.VSIFCloseL(f)
return content
gdal.VectorTranslate('out.json', """{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "geometry": { "type": "Polygon", "coordinates": "coordinates":[[[-188.56933593749997,61.58549218152362],[-173.9794921875,61.58549218152362],[-173.9794921875,66.00015035652659],[-188.56933593749997,66.00015035652659],[-188.56933593749997,61.58549218152362]]] } },
]
}""", format = 'GeoJSON', layerCreationOptions = ['RFC7946=YES', 'WRITE_BBOX=YES'])
got = read_file('/vsimem/out.json')
gdal.Unlink('/vsimem/out.json')
print json.loads(got)
from this answer, the file out.json is empty. The folder is with all permissions for writing allowed. When testing the method gdal.OpenEx, is possible to load an object, but still the method gdal.VectorTranslate returns an empty geojson when trying to pass this new loaded object as a srcDS object. Any hint on solving this issue?
Python 2.x, is there a significant change in the method signature? – Ricardo Barros Lourenço Sep 13 '17 at 12:14gdal.VectorTranslateis only available in GDAL 2x,not GDAL 1.x – user2856 Sep 13 '17 at 12:21GDAL 2.1.xonPython 2.x, but when I use the code you've written, it dumps an empty JSON. Perhaps is an issue on my package install (I'm using GDAL on a MacOS). – Ricardo Barros Lourenço Sep 13 '17 at 12:30RFC7946=YEScreation option is only supported at GDAL >= 2.2 as stated in the GeoJSON driver documentation – user2856 Sep 14 '17 at 02:35