In PostGIS, we are trying to select the rows in a table of points (
point_table) that are within a polygon, which is stored in a separate relation (
poly_table). Having dug around for hours, we can't work out how to get our desired result, all the points within each polygon.
The closest we've gotten (i.e. no errors) is below, which returns 0 rows:
SELECT * FROM point_table as p WHERE ST_Within(p.point::geometry, (SELECT polygon FROM poly_table WHERE objectid=1)::geometry);
We did get a result of all
FALSE boolean values from the query below, which we think is why the query above returns 0 rows...
SELECT ST_Within(p.point::geometry, (SELECT polygon FROM poly_table WHERE objectid=1)::geometry) FROM point_table as p;
We added these explicit type casts because any alternative threw an error, even though both the
poly attributes are