[Qgis-developer] Python: Select features that touch other features
Andreas Neumann
a.neumann at carto.net
Tue Oct 8 06:10:10 PDT 2013
Thank you Daniel, Nathan and Marco for all your hints.
I am sure I will manage to do what I want with all of your suggestions!
Andreas
Am 06.10.2013 02:00, schrieb Daniel:
> Using map() is the pythonic way
>
>
> Maybe ftools need an upgrade :)
>
> Thanks for the tip
>
>
> On Sat, Oct 5, 2013 at 8:53 PM, Nathan Woodrow <madmanwoo at gmail.com> wrote:
>
>>
>> On Sun, Oct 6, 2013 at 9:45 AM, Daniel <danielvaz at gmail.com> wrote:
>>
>>> def createIndex( provider ):
>>> feat = QgsFeature()
>>> index = QgsSpatialIndex()
>>> fit = provider.getFeatures()
>>> while fit.nextFeature( feat ):
>>> index.insertFeature( feat )
>>> return index
>>>
>>
>> Try something like this for your createIndex which will work with any
>> collection of features:
>>
>> def createIndex( features ):
>> index = QgsSpatialIndex()
>> map(index.insertFeature, features)
>> return index
>>
>> index = createIndex(provider.getFeatures())
>>
>> and also because I hate seeing while nextFeature() used :)
>>
>> - Nathan
>>
>>
>>
>
>
More information about the Qgis-developer
mailing list