Skip to main content
edited tags; edited title
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Best way to find the Finding polygons crossed by a line using OGR?

edited tags
Link
lynxlynxlynx
  • 4.3k
  • 3
  • 31
  • 46
Source Link
Marc
  • 317
  • 1
  • 4
  • 15

Best way to find the polygons crossed by a line

I'm trying to find all the polygons crossed by a single line (a GPS track). I'm using the OGR library (from python) for computing this, but it's currently a bit 'brute-force' (and slow). For every point of my track, I call the intersect method with all the polygons. The obvious optimization is to check only with adjacent polygons. But I guess this is a classical problem, with an already known solution (which I can't find...).

I would like to avoid using a dedicated database as I'm trying to write a standalone software (spatialite is an option if the DB is the way to go).

(FYI, the current source code is available here: https://github.com/dkm/airspace-checker )