Skip to main content

Posts

Showing posts from November, 2010

Converting shapefiles (SHP) to a different projection

I've written a small perl script to handle converting the coordinates in shapefiles to a different coordinate set. You must specify the source EPSG projection and the destination EPSG projection, and the script will walk through the data and create a new shapefile with the coordinates transformed by using the new projection. The new files are saved next to the original files, with the projection number appended to the file names. Currently the script supports POINT data and LINESTRING data. All other geometries are ignored. In order to use this script you will need to have the following packages installed (example for ubuntu): shapelib, proj-bin, gdal-bin Sample usage: adrianp@frost:~/bin$ ./convertSHPProjection.pl epsg:4326 epsg:31700 ofm_fiber.shp Going to save data as ofm_fiber_31700.[shp/shx/dbf] Depending on your data size, this may take a while... Copying dbf file... Code: #!/usr/bin/perl use strict; use warnings; # Author: Adrian Popa # License: