Search code examples
postgresqlpostgisoverlaparea

how to calculate the overlap area - postgis, postgres?


how to calculate the overlap area?

select ST_Area(ST_Overlaps(geometrya, geometryb)::geometry) from table_name;

Error Message cannot cast type boolean to geometry


Solution

  • ST_OVERLAPS returns a boolean indicating if the geometries do or not overlap each other. To get the geometry of the intersection you can use ST_INTERSECTION

    select ST_Area(ST_INTERSECTION(geometrya, geometryb)) from table_name
     WHERE ST_Overlaps(geometrya, geometryb);