What is the equivalent in QGIS (or other FOSS) to this:
rows = arcpy.SearchCursor(table, fields="ORIG_FID; field1; field2; field3; field4", sort_fields="ORIG_FID A") for row in rows:
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Hacking together the examples there:
# The expression will filter the features where the field "location_name" contains # the word "Lake" (case insensitive) exp = QgsExpression('location_name ILIKE \'%Lake%\'') request = QgsFeatureRequest(exp) request.setSubsetOfAttributes(['name','id'],layer.pendingFields()) for feature in layer.getFeatures(request): # do whatever you need with the feature
Also, see this question for some other hints: What are QGIS Arcpy Equivalent Functions for Update/Delete Row/Field?
.getFeatures(), this returns all layer field values:
Query the provider for features specified in request.
for feature in table.getFeatures(): if feature['myField'] == someVariable: # do something