Howard Butler wrote:
On Mar 26, 2010, at 12:03 PM, Yevgen Antymyrov wrote:
Guys,
I've found this old conversation about Python vs C comparison and I have a
question about it. If you don't mind, I'll continue the old thread.
My current task is to go through a big file, then for some particular
features(F1) I need to find all features(F2) in another file which intersect
the F1. For that I used shape to speed up the search of F2 by using
layer.SetSpatialFilterRect().
Do you really want a union?
http://sgillies.net/blog/993/shapely-1-2a6-with-pictures/
Alternatively, if you just are detecting intersection use an index (Rtree would
work great) and then use Shapely to test those hits the index says have
coincident bounding boxes for actual intersection. This approach is going to
be much more memory efficient than trying to load all of your file into ram and
testing them.
Howard
No, union is of no use here. I need to print out all points of
intersection between specific types of features. But the issue is with
memory leak, not with the algorithm.
What I've just found is that if I do in the inner loop instead of using
the same layer2 and doing this:
"
layer2.SetSpatialFilter(None)
layer2.ResetReading()
"
just do stupid:
"
source2 = ogr.Open(myfile)
layer2 = GetLayerByName("lines")
"
then all the memory problems disappear. I think when I rewrite 'layer2'
and 'source2' objects, they get GC-ed and all the features get cleaned.
So the question still remain, how to explicitly deallocate memory for
each feature? Doc string for .Destroy() says it's already deprecated.
Once again, sorry for posting this to the wrong mail list, it's just I
saw Sean Gillies writing something about memory and decided to try my
luck.//
--
Yevgen
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community