4

I've got a large set of LAT/LON coordinates. Up until now, when I needed to select out those that fell within a certain region, I'd just create a bounding box using some MINx, MAXx, MINy, MAXy values and try to get it as close as possible to the area I was interested in.

I'd like to get more precise by using more than 4 points as the extent of my search area, in this specific case, 14 points.

I'll probably be using Python or SQL for this, so the specific syntax on any solution isn't that important, I'm just interested in the formula for figuring this one out.

4

You could use Shapely to perform the operation (e.g. within). You could load both geometries via one Shapely's methods for interoperation.

2

PostGIS has a collection of relational operators that should do what you want.

  • SELECT * FROM pointstable, polygonstable WHERE st_intersects(pointstable.geom, polygonstable.geom)=TRUE – Pablo Jul 1 '11 at 22:01
  • 1
    specifically: ST_Contains or ST_Within (possibly ST_DWithin if you want to overcompensate for rounding errors) – Mike T Jul 1 '11 at 23:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.