Last active
September 26, 2022 15:19
-
-
Save thbaumann/2321f1f655ba44dea09b4ccddc39aa1f to your computer and use it in GitHub Desktop.
test_temp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iterating over the input layer : | |
for m in municip.getFeatures(): | |
inh_center = m['EWZ'] | |
# | |
# central municipalites with 0 inhabitants must be excluded; the value of "center_pos" will be set to -1. | |
if inh_center == 0: | |
center_pos = -1 | |
dict = {m.fieldNameIndex('center_pos'):center_pos} | |
municip.dataProvider().changeAttributeValues({m.id(): dict}) \ | |
# | |
# Extract by location: | |
else: | |
key = m['AGS'] | |
selection_expression = '\"AGS\" = ' + str(key) | |
municip.selectByExpression(selection_expression,QgsVectorLayer.SetSelection) | |
result = processing.run("qgis:extractbylocation",{'INPUT':QgsProcessingFeatureSourceDefinition(municip.id(),False),'PREDICATE':4,'INTERSECT':QgsProcessingFeatureSourceDefinition(municip.id(),True),'OUTPUT':'memory'}) | |
extracted = result['OUTPUT'] | |
count_all = extracted.featureCount() | |
countsmall = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment