[Qgis-developer] Modifications to dissolve() in fTools
eliott.coyac at gmail.com
Thu Jun 14 15:11:24 PDT 2012
Recently for a project I've needed to work with the fTools plugin. One
of the thing I had to
do was to load a great number of points (over 1M) and bufferize them,
then dissolve the
I've made several changes to dissolve, but since I'm new on this list
and I don't know how
things work here I'm only submitting the first one:
Currently, when dissolving based on a field, fTools first makes the list
of different values,
then for each value goes through the entire features, and for those
matching the field value
combines them. If there is a large number of different values (for
example 1000 different values)
it means that fTools will have to go through the whole layer 1000 times.
(rewinding the provider
every time, etc.). For large layers it is too slow.
What I do instead is keep a dictionary of features, one feature per
field value. For each feature
of the layer, I check if the field value is already associated to an
open feature, and if so,
I combine the features (otherwise I create the feature and add it to the
dictionnary). That way, I go through the layer only once.
Here is the patch (in the case when the "selection only" box is unchecked):
I also have a .shp test file (58 MB) that I can upload, to compare the
difference in speed (at least
a factor 10).
I hope I went through proper channels and didn't make a blunder with the
code (it works fine here)
More information about the Qgis-developer