I want to convert all lines from a .osm-File to a geojson with the gdal Python API.
My Code so far:
from osgeo import gdal
from osgeo import ogr
gdal.UseExceptions()
srcds = gdal.OpenEx("infile.osm")
gdaloptions = gdal.VectorTranslateOptions(format="GEOJSON", layers = ["lines"])
ds = gdal.VectorTranslate("outfile.geojson", srcds, options=gdaloptions)
This returns a lot of erros like:
ERROR 1: Non increasing node id. Use OSM_USE_CUSTOM_INDEXING=NO
According to the Documenation of VectorTranslateOptions() I changed gdaloptions to:
gdaloptions = gdal.VectorTranslateOptions(options=['OSM_USE_CUSTOM_INDEXING=NO'],
format="GEOJSON",
layers = ["lines"])
But this returns an other error: Couldn't fetch requested layer OSM_USE_CUSTOM_INDEXING=NO!
How do I set this "Open Options" of the osm-Format within the VectorTranslateOptions
?