I have a series of shapefiles, that have 3D geometries (ie: points ZM). I would like to remove the 3D geometry so that the files are 2D. Is there a way to remove 3D geometry from a shapefile using OGR?
Write your data into a new shapefile with ogr2ogr and force geometry type into 2D with the -dim switch.
ogr2ogr -f "ESRI Shapefile" output_2d.shp input_zm.shp -dim 2
The -dim setting is not limited to shapefiles but works in the same way for most vector formats. One exception I know is Oracle Spatial that does not honour the ogr2ogr switch but you must use the layer specific
Once your shapefile is read as
ogr.Geometry, you can use its
See the GDAL documentation.