0

I am attempting to use OGR2ORG on Mac OS X to loop through 30 shapefiles, change their projection and save the files into a new directory. I am new to using Macs and the OGR2OGR command line environment.

The original files are in /data/ChicagoBaseLayers/clipped. I would like the reprojected layers to go to /data/ChicagoBaseLayers/Projected.

After navigating to the 'clipped' directory on the command line, I tried

for %f in (*.shp) do ogr2ogr -t_srs EPSG:3857 -s_srs EPSG:4326 /Users/stevenchong/data/ChicagoBaseLayers/Projected/%f Users/stevenchong/data/ChicagoBaseLayers/clipped/%f

but I get the error message: syntax error near unexpected token `('

What am I doing wrong?

3

That looks a lot like a windows style 'for loop' and if you enter it in one single line, without ';' in place of where the newlines need to be, you could get some errors.

Try doing it in Linux style!

cd /Users/stevenchong/data/ChicagoBaseLayers/clipped; for f in *.shp; do ogr2ogr -t_srs "EPSG:3857" -s_srs "EPSG:4326" ../Projected/${f} ${f}; done

That's probably a better way to enter it into the terminal on one line.

  • It worked! Thanks for the helpful explanation too! – stevenchong Jul 15 '14 at 9:23

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.