-
-
Save dimasmaulana99/93f28c1056337822a11c823633e272a6 to your computer and use it in GitHub Desktop.
A QGIS Python snippet to select multipart features in the active layer
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
# Find all multipart features in the active layer | |
layer = iface.activeLayer() | |
# Clear the selection first | |
layer.removeSelection() | |
# Iterate through features and select the multipart ones | |
for feature in layer.getFeatures(): | |
geom = feature.geometry() | |
if geom.isMultipart(): | |
layer.selectByIds([feature.id()]) | |
print('Multipart features selected:', layer.selectedFeatureCount()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment