Search code examples
postgresqlpostgisqgis

PostGIS and coordinates, determinate if a point is inside a multipolygon


I have the coordinates: -48.54367281530538 -15.91180231568948

I need to know if these coordinates belong to my multpolygon

select boolean st_contains(st_geomfromtext('POINT(-48.54367281530538 -15.91180231568948)',4326), st_geomfromkml(a.geom)) 
from "LIM_Municipio_A" as a
where nome  ilike 'alexânia';

My Table:


Solution

  • The doc says:

    boolean ST_Contains(geometry geomA, geometry geomB);
    Geometry A contains Geometry B if [...]

    So you would have to use the polygon first, then the point.

    select st_contains(
        st_geomfromkml(a.geom),
        st_geomfromtext('POINT(-48.54367281530538 -15.91180231568948)',4326)
       ) 
    from "LIM_Municipio_A" as a
    where nome  ilike 'alexânia';