Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm new to Open Street Map and PostGIS, and am trying to figure out how to find all of the ways that intersect a linestring (i.e. all of the streets that intersect a route). Is there a way to do this that doesn't involve calling ST_Intersects on every row of the table?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

What you are looking for is only checking for intersecting within a bounding box. See: Selecting by bounding box with PostGIS

share|improve this answer
1  
Just to be clear: you're not saying that ST_Intersects and intersection with the BB are the same thing; you're simply suggesting making a preliminary selection based on intersection with the BB and following that up with the ST_Intersects tests, right? –  whuber Jan 1 '12 at 14:46
    
Yes, sorry it was newyear night and i drank a lot of champagne. I could have been a little bit more elaborate. –  mrg Jan 1 '12 at 15:26
    
ST_Intersects makes a bbox (if possible index-based) first selection before doing the "real" computation. –  Nicklas Avén Jan 2 '12 at 20:59
    
Thanks, I ended up getting all of the lines that intersect the linestring's bounding box and then used ST_DWithin to find the intersections. –  Marc Regan Jan 12 '12 at 17:34
    
I find it a bit weird to use ST_DWithin for your needs. Do you check on distance = 0? –  mrg Jan 12 '12 at 19:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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