0

I'm doing a spatial query in PostGIS wanting to get all objects within a given polygon or with some feature inside that polygon. PostGIS only returns objects that are inside the polygon. Those objects that have part of their feature inside this polygon are not being returned by the query.

We are using ST_CONTAINS but it only returns objects that are inside the polygon.

Query:

SELECT ID, TIPO, St_AsText(ST_Transform(C.COORDENADAS,5641)) COORD 
FROM POLYGONS_GEOMETRY C 
WHERE ST_Contains(ST_GEOMFROMTEXT('SRID=5641;POLYGON((a b c d))'), C.COORDENADAS)

In the image, the objects in red returned portque are within the limit, however the other objects did not return because only part of them are within the limits

  • 4
    I think you're looking for ST_Intersects() – pdavis Jan 24 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.