I'm trying to take a shapefile that can be downloaded here (specifically the shapefile titled PVS_19_v1_vtd_21031.shp), convert it from EPSG:4269 to EPSG:3857, and output the GeoJSON into CSV with only XY coordinates. Currently, all steps work, except I'm still receiving a trailing 0 coordinate. Here's my command:

ogr2ogr -f csv -dialect sqlite -t_srs epsg:3857 -sql "select AsGeoJSON(geometry) AS geom, * from PVS_19_v1_vtd_21031" PVS_19_v1_vtd_21031.csv partnership_shapefiles_19v1_21031/PVS_19_v1_vtd_21031.shp -dim 2

and here's some sample output:


How can I drop the trailing 0 coordinate (I assume it's intended to be a Z coord?)

| improve this question | | | | |

You can cast your geometry as XY before outputting it to GeoJSON:

ogr2ogr -f csv -dialect sqlite -t_srs epsg:3857 -sql "select AsGeoJSON(CastToXY(geometry)) AS geom, * from PVS_19_v1_vtd_21031" PVS_19_v1_vtd_21031_2D.csv partnership_shapefiles_19v1_21031/PVS_19_v1_vtd_21031.shp -dim 2

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.