Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have thousands of shapefiles with coordinates in lat/long (-180 to +180 x, -90 to +90 y), that contain polygons of which I wish to calculate the area.

I'm using the Python GEOS/OGR/GDAL API. If I call the Area() function for each geometry, I'll get the 2D area, or the area on a Mercator projection (basically). Since the polygons are really on a sphere, I want to convert them to an equal area projection before I calculate the area. I was wondering if anyone had any experience with this on here.

Some reading of the documentation suggested there were functions somewhere in OSRSpatialReference to transform a point or geometry from one projection to another, but it wasn't quite clear to me exactly how to use this or what projection to use.

Any help would be greatly appreciated. Thanks much!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I would use org2ogr to do the reprojection of each file and wrap the command line in a for loop.

#!/bin/bash
for i in *.shp
do
   x=`basename $i .shp`
   outfile = ${x}_eqa.shp
   ogr2ogr -t_srs epsg:xxxx $outfile $i
done

You'll need to go to spatialreference.org to look up a relevant epsg code for an equal area projection for your region if you don't know one off the top of your head.

share|improve this answer
    
Thanks very much iant. –  Ben Apr 20 '12 at 1:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.