Skip to content

Instantly share code, notes, and snippets.

@luipir
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luipir/fcbc318304944962dfec to your computer and use it in GitHub Desktop.
Save luipir/fcbc318304944962dfec to your computer and use it in GitHub Desktop.
mutual exclusivity in QgsFeatureRequest
myVector = iface.activeLayer() # alaska.shp in qgis_sample_data
# iteration getting only selected features
rect = QgsRectangle( 1223070.695, 2293653.357 , 9046974.211, 4184988.662)
request = QgsFeatureRequest()
request.setSubsetOfAttributes([0, 2])
request.setFilterExpression('"AREA_MI" > 1000')
request.setFilterRect( rect )
for index, feature in enumerate( myVector.getFeatures( request ) ):
print "The record %d has ID %d" % ( index, feature.id() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment