Batch SHP to CSV Conversion with Reprojection
The following Shell script performs a conversion and reprojection of a folder full of Shapefiles to CSVs:
for f in `ls *.shp`; do
ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:3035 -f CSV $f.csv $f -lco GEOMETRY=AS_XYZ
Works like a charm, nice
I think the first line can be
for f in *.shp; do
which will work even if the user has aliased ls to something odd.
In addition to Ian’s comment, rather than having two extensions (“prefix.shp.csv”), you can rename it to have only one (“prefix.csv”):
with: `basename $f .shp`.csv
Thanks for the tips! I’m new to Shell scripting.