Reprojecting several shape files in a folder with ogr2ogr
Today I received a lot of shape files from Stockholm municipality. The files are all in a local projection,
Sweref 99 18 00 and I need them all to be reprojected into
Sweref 99 TM. Normally I use the GDAL tool ogr2ogr to reproject a shape file, but it would take all afternoon if I had to write
ogr2ogr -t_srs EPSG:3006 file.sweref99TM.shp file.shp with every file!
So instead I created a simple shell script which consists of a for loop and then the ogr2ogr command:
The part with
-t_srs EPSG:3006 defines the target projection, which in this case is
Sweref 99 TM. Since the original shape file already has a projection defined in the file I don’t have to set any source projection, only target.
I put this script in the folder where I’d like to reproject the files and then run it with
sh reproject_folder.sh in the Terminal.
Note: this was all made on a Mac but will probably work fine on any unix machine. In Windows I think you have to change the $ to % to make it work, but I’m not sure.
GDAL with ogr2ogr for Mac can be downloaded over at Kyngchaos.com.