Gianmarco F.
Gianmarco F.

Reputation: 800

PostGIS and coordinates, determinate if a point is inside a polygon/multipolygon (kml)

My goal is to determinate if a point (coordinate) in Input is inside the polygon (both the point and polygon/multipolygon are geographic objects from postGIS). Now my query always return false.

Basically this always returns false even if the point is inside the polygon:

select st_contains(st_geomfromtext('POINT(42.17591110412206 13.716918686169493)',4326),st_geomfromkml('<Polygon><outerBoundaryIs><LinearRing><coordinates>13.722101,42.177614,0 13.72....... </Polygon>')
);

i truncated the kml of course, anyway the format is (lat,lng,0), also on the point i used 4326 and i'm not sure if the value is correct. Also i tried both

Point(LAT,LNG) and Point(LNG,LAT)

Could anyone help me? I'm really out of ideas, surely there is something wrong on my query.

Upvotes: 0

Views: 1472

Answers (1)

kret
kret

Reputation: 158

Actually, regarding to official documentation (https://postgis.net/docs/ST_Contains.html):

boolean ST_Contains(geometry geomA, geometry geomB);

Returns TRUE if geometry B is completely inside geometry A.

A point cannot contain polygon ;)

Upvotes: 1

Related Questions