You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sergio Botero edited this page Mar 12, 2014
·
1 revision
QgsSpatialIndex
A cool feature on the QGIS API is the QgsSpatialIndex. I tried to use it but it does not work for us.
index=QgsSpatialIndex()
forfeatureinprovider.getFeatures(): # feature as each area with its geometryindex.insertFeature(feature)
Now using the index.intersects(feature.geometry()) (and you can add a buffer to the geometry with feature.geometry().buffer(10, 2)) we get a list of features that intersect with the geometry of the feature we are testing. The Problem with this is that the geometry used are bounding boxes and when having map and irregular shapes, an intersection can show neighbors that are not spatial neighbors.
If there is a way to avoid this kind of errors while using the Spatial Index, would be a good alternative since the use of it really seems to speed up the implementation.