Thursday, 13 February 2020

postgis - Finding all polygons inside of a polygon


How to find all the polygons inside of a polygon? I tried ST_Intersects and ST_Contains but they are booleans variables. I have a list of polygons in WKT format, so I am trying to pull all the polygons given a region in their WKT format.


Does anyone have an idea how to approach this?


select geom from polygon where 
ST_Intersects(ST_GeographyFromText

('POLYGON((210000 2400000, 300000 2300000, 330000 3708400, 210000 2400000))'),
polygon.geom);

Answer



You are missing ST_AsText, as @WKT mentions above. This should work for you:


select ST_AsText(geom) from polygon
where ST_Intersects(ST_GeographyFromText
('POLYGON((210000 2400000, 300000 2300000, 330000 3708400, 210000 2400000))'),
polygon.geom);

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...