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.


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

for i in *.shp
   x=`basename $i .shp`
   outfile = ${x}_eqa.shp
   ogr2ogr -t_srs epsg:xxxx $outfile $i

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.

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.