Is there a gdal or python based tool for converting Polygons and MultiPolygons inside of GeoJSON to LineStrings and MultiLineStrings? I'm using rasterio / rio rasterize or gdal_rasterize to rasterize GeoTIFF w/ GeoJSON.
I need to read in GeoJSON files and be able to convert any (Multi)Polygons into LineStrings and MultiLineStrings so I can rasterize just the boundary or outline of the (Multi)Polygons onto GeoTIFFs (this includes exterior and interior polygons) and not have it fill in the entire shape.
Any ideas?
Best Answer
With ogr2ogr you can do it with the SQLite dialect and the ExteriorRing function from SpatiaLite http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html
Test with ogrinfo and shapefile
This should work for you:
Check first with
ogrinfo my_file.json
what is the layer name in your source data.I believe that you can use the same SQL of SQlite dialect directly as an input for gdal_rasterize http://www.gdal.org/gdal_rasterize.html without creating an interim file.