12

Possible Duplicate:
What is the most accurate coordinate system for calculating areas of polygons?

In our Postgres/Postgis database we store polygons in a column defined as lonlat/EPSG:4326, as it may contain data from anywhere in the world.

We have a requirement to calculate the surface area (i.e. in square meters or hectares). The method ST_Area can perform the calculation but returns the answer in the used coordinate systems units. That is, it returns the area as what I believe is "square degrees". As the size of a degree is variable depending on the location in the world, this does not make much sense.

One solution is to transform (ST_Transform) the polygon to another crs before calculating the area, perhaps the appropriate UTM32 zone, but that will require us to dynamically determine the zone first. Alternatively we could always transform to the Google Mercator (EPSG:900913), but we fear for the precision.

Any inputs?

1
  • try SELECT ST_Area(geom::geography)
    – Mike T
    May 30, 2012 at 19:40

1 Answer 1

19

I found a function to return the UTM zone for any point on the PostGIS wiki: utmzone()

Using that you could do:

SELECT
ST_Area(
ST_Transform(the_geom, utmzone(ST_Centroid(the_geom))
)) 
FROM polygons
WHERE...

HTH, Micha

2
  • Could you tell me what unit the result is? (km^2, or hecta, or m^2) Thanks!
    – Jackie
    Dec 3, 2014 at 10:05
  • 4
    The calculations of ST_Area (and other functions) will always be in the same units as the Coordinate System. The above refers to UTM, with units in meters, so the area will be sq meters.
    – Micha
    Dec 4, 2014 at 12:31

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