Personal tools
You are here: Home Documentation FAQs Converting Projections for Shapefiles using OGR2OGR

Converting Projections for Shapefiles using OGR2OGR

Document Actions
Up to table of contents
I need to reproject my shapefile to meters in order for it to work with Mapserver. How is this done?

With ogr2ogr of course! ogr2ogr is a powerful utility that will transform the projections of your shapefiles when passed the appropriate parameters. In my case, I was using Mapserver to serve data in RI State Plane Feet. In order to do so, the data had to first be converted to meters. Here is the command I used:

ogr2ogr -t_srs EPSG:32130 output.shp input.shp

Since my data already had a projection defined, I did not need to explicitly state a source projection. This command uses the EPSG definition for NAD83 Rhode Island (32130) and performs the feet to meters conversion.

Now say my data wasn't already projected? Here's how we deal with that:

ogr2ogr -s_srs "+proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.999994 +x_0=100000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3408 +no_defs" -t_srs EPSG:32130 output.shp input.shp

Let's examine what is going on here:

The -s_srs parameter explicitly defines a projection for the data. The parameters used here were taken out of the EPSG definition (in this case, 32130) in the epsg file(see the projection FAQ for more details on locating EPSG definitions). The entry for RI in the epsg file is as follows:

# NAD83 / Rhode Island
<32130> +proj=tmerc +lat_0=41.08333333333334 +lon_0=-71.5 +k=0.999994 +x_0=100000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs  no_defs <>

You can see how the definition in the initial command is formulated. Notice that the "+units=m" parameter has been changed to “+to_meter=0.3408”. This is important for the conversion. Where did the value of 0.3408 come from you ask? From the EPSG file! It has many goodies buried in it so by simply running 'grep "to_meter" epsg’ you can refresh your memory if you need to.

The next parameter in the command is "-t_srs EPSG:32130". This command tells ogr2ogr to transform the data to the EPSG code of 32130. After this is declared, all you need to do is declare a file name for your new shape file and to set which file is being used as the input (note: make sure you don’t confuse the order of these two).

Hit enter, bombs away, and enjoy your new data in meters!

This FAQ applies to: Any version.

by Joe Conlin last modified 2006-07-05 15:17
Contributors: Joe Conlin

Converting to Alaska Albers Equal Area Conic

Posted by Amelia Dieken at 2007-11-08 18:55
I'm new to MapServer and am having trouble figuring out how to project my map to Alaska Albers Equal Area Conic. Currently it is in geographic coordinate system (GCS). Could anyone help me out?

Powered by Plone