Search code examples
postgresqlpostgis

What is the area of geom field?


I want to check the area of geometry values.

The geometry values are POLYGON or POINT or MULTI POLYGON. The field has the type of geometry

I check the srid of the geom field:

select st_srid(geometry) 
from my_table

And I got srid=32636.

I checked here: https://epsg.io/32636 and it seems that the units are in meters.

Now I want to get the area (in meters) of each value:

select st_area(geometry)
from my_table

And I'm getting very small values (0.0002, or 0.000097 or 0.33, ....).

I want to be sure:

  • Does those values means square meter (m^2) ?
  • So the values are less than 1 square meter ?

Solution

  • Since your SRS unit is metre, ST_Area will return the area in square metres. The following example calculates the area of a polygon using SRS's that have different units:

    WITH j (geom) AS (
      VALUES ('SRID=32636;
              POLYGON((-1883435.029648588 6673769.700215263,-1883415.1158478875 6673776.142528819,-1883411.8478185558 6673765.073005969,-1883431.7724919873 6673758.967942359,-1883435.029648588 6673769.700215263))'::GEOMETRY)) 
    SELECT 
      ST_Area(geom) AS sqm,
      ST_Area(
        ST_Transform(geom,2249)) AS sqft 
    FROM j;
    
            sqm        |       sqft        
    -------------------+-------------------
     237.6060612927441 | 2341.135411173445
    
    • EPSG 32636: Units are metres (Ellipsoid WGS84)
    • EPSG 2249: Units are feet (Ellipsoid GRS1980)

    To your questions:

    Does those values means square meter (m^2) ?

    Yes.

    So the values are less than 1 square meter ?

    Yes. I'm curious about what are your geometries about. Perhaps you mixed up different SRS?

    Unrelated note: Spatial operations with SRS's that have the same unit might still deliver different results, as they might also use different ellipsoids. The example below will calculate the area of the same geometry using SRS's that have metre as unit but a different ellipsoid. Note the difference in the result:

    WITH j (geom) AS (
      VALUES ('SRID=32636;
              POLYGON((-1883435.029648588 6673769.700215263,-1883415.1158478875 6673776.142528819,-1883411.8478185558 6673765.073005969,-1883431.7724919873 6673758.967942359,-1883435.029648588 6673769.700215263))'::GEOMETRY)) 
    SELECT 
      ST_Area(geom) AS sqm_32636,
      ST_Area(
        ST_Transform(geom,26986)) AS sqm_26986
    FROM j;
    
    
         sqm_32636     |     sqm_26986      
    -------------------+--------------------
     237.6060612927441 | 217.49946674261872
    
    • EPSG 32636: Units are metres (Ellipsoid WGS84)
    • EPSG 26986: Units are metres (Ellipsoid GRS1980)

    .. but if you stick to the same ellipsoid and unit, the math makes more sense:

    WITH j (geom) AS (
      VALUES ('SRID=32636;
              POLYGON((-1883435.029648588 6673769.700215263,-1883415.1158478875 6673776.142528819,-1883411.8478185558 6673765.073005969,-1883431.7724919873 6673758.967942359,-1883435.029648588 6673769.700215263))'::GEOMETRY)) 
    SELECT 
      ST_Area(
        ST_Transform(geom,2249)) AS sqft_2249,
      ST_Area(
        ST_Transform(geom,2249)) * 0.3048 ^ 2 AS sqm_2249, -- manually converted from sqm to sqft
      ST_Area(
        ST_Transform(geom,26986)) AS sqm_26986
    FROM j;
    
         sqft_2249     |      sqm_2249      |     sqm_26986      
    -------------------+--------------------+--------------------
     2341.135411173445 | 217.49859674966302 | 217.49946674261872
    

    Demo: db<>fiddle