PostGIS和坐标,确定点是否在多边形内

时间:2020-04-17 14:01:05

标签: postgresql postgis qgis

我的坐标是:-48.54367281530538 -15.91180231568948

我需要知道这些坐标是否属于我的多角形

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';

我的桌子:

1 个答案:

答案 0 :(得分:2)

doc说:

布尔值ST_Contains(几何 geomA ,几何 geomB );
如果[...]

,则几何A包含几何B。

因此,您必须先使用多边形,然后再使用点。

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';