I am trying to match a large set (43M) of small circular polygons to a smaller set of very large polygons.
To make this process as fast as possible I've created points from the centers of the small polygons and have successfully matched them to the the larger polygons substantially faster than before using the following code:
Large_poly_layer > The very large polygons pts > points data source
for large_poly in Large_poly_layer:
polygeom = large_poly.GetGeometryRef()
pts.SetSpatialFilter(polygeom)
for pt in pts:
fid = pt.GetFID()
// this then writes the FID to a numpy array
pts.SetSpatialFilter(None)
Now what I am trying to do is obtain any points that didn't match, so that I can buffer them into polygons and see if they'll match at that points.
I think the fastest way to do this would be to do the inverse of the spatial filter but I cannot find a decent way to do it.
I have also attempted the following:
-copying the whole large point dataset to a memory layer in ogr then deleting points that have matched, but the lack of spatial indexing in the memory format makes this process incredibly slow.
-I also cannot write back to the original source data as it is contained in a .gdb file