简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM