The problem:
I have a very large vector layer with many features and a much smaller raster layer in a defined region. I want to get only those vector features which are within the raster layers extent (extent = (xmin,xmax,ymin,ymax)
).
Is there anything like a standard SQL-query (something like SELECT * FROM layer WHERE EXTENT < extent
) or another command (some test?) i could use to get only those features that are within a given extent?
EDIT:
Added python code to do a bounding box intersection test for vector features using just gdal and ogr python binding
Best Answer
You don't need a SQL-query to do that, only Python with, once again, the modules Fiona and Shapely of Sean Gillies.
I want only the records which are within the blue frame (analogy of a raster layer).
See the Fiona user Manual, the filter() method returns an iterator over records that intersect a given (minx, miny, maxx, maxy) bounding box:
Result: