Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 99589

Use this tag when asking questions about a representation of a real-world objects on a map.

1 vote
Accepted

Why wont QGIS let me export selected features only?

As was already mentioned by @JGH, for a successful export, targeted features have to be selected. For more details about 'selecting features', please use the documentation. …
Taras's user avatar
  • 34k
1 vote

Getting number of features in the Attribute table using PyQGIS

Another option can be the allFeatureIds() method from the QgsFeatureSource class: num_of_features = len(layer.allFeatureIds())
Taras's user avatar
  • 34k
1 vote

Selecting only N records from layer using PyQGIS

Another option is to use the "Random selection" tool for selecting N random features. import processing from qgis.utils import iface layer = iface.activeLayer() processing.run("qgis:randomselection", …
Taras's user avatar
  • 34k
5 votes

Searching for values in different layers without nested for loops using PyQGIS

Referring to several features If only targeting features' ids should be requested, then one case get them via the getFeatures() method together with the QgsFeatureRequest() and setFilterFids(). … ) Referring to all features In case when all features should be requested use simply the getFeatures() method: layer = iface.activeLayer() features = list(layer.getFeatures()) …
Taras's user avatar
  • 34k
3 votes

Returning current attribute name in QGIS Expression Dialog

Try using the following expression attribute($currentfeature, 'field_name') in the "Expression Dialog", see image below In Record and Attributes Function attribute Returns the value of a specified a …
Taras's user avatar
  • 34k
1 vote

Difference between two features in same polygon in QGIS

If I understood the question correctly, you want to achieve two layers: First that contains only overlapping features Second that includes features with no overlaps Let's assume there is a polygon layer …
Taras's user avatar
  • 34k
3 votes

Getting the bounding box for each feature in the source layer in QGIS

There is a possibility using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... Let's assume there is a polygon layer called 'test' with its corresponding attribute tables, see im …
Taras's user avatar
  • 34k
2 votes

Selecting values in attribute table which have alternate same values in two different columns

Use the "Select by expression" from the Selection Toolbar with the following expression: array_contains( string_to_array( concatenate_unique("fid_2") ), "fid") Usually fields …
Taras's user avatar
  • 34k
5 votes

Replica of point layer data from attribute value in QGIS

Let's assume there is a point layer called 'Centroids' with three features in it, see the image below. The field "Number" will be used for producing copies of each feature. Step 1. … Apply the "Array of translated features" geoalgortihm (available in QGIS 3.4). In the 'Number of features to create' field use the following expression: "Number" - 1 Step 2. …
Taras's user avatar
  • 34k
2 votes

Hiding data attributes rows in the Identify Results panel

This is the current result after using the "Identify Features" tool (Ctrl+Shift+I). … layer.fields()[index] widget_setup = QgsEditorWidgetSetup(type, config) layer.setEditorWidgetSetup(index, widget_setup) Press Run script and get the final output (again after using the "Identify Features
Taras's user avatar
  • 34k
5 votes
Accepted

AssertionError when applying expression to field value with PyQGIS

Another workaround was shown in this thread Setting attribute values using PyQGIS in an edit session. layer=QgsVectorLayer(r"C:\Users\ANI\Documents\SIG\fossés\pythontest\mergedlinef1.shp") features=layer.getFeatures …
Taras's user avatar
  • 34k
5 votes

Setting selected features in list without specifying their layer using PyQGIS

There is a special method for deleting selected features called deleteSelectedFeatures(). … Cheat sheet for PyQGIS Deleting selected features using PyQGIS Getting attributes of selected features using PyQGIS …
Taras's user avatar
  • 34k
12 votes

Rotating features with multiple geometries in one layer using PyQGIS

References: Rotating features in memory layer using PyQGIS …
Taras's user avatar
  • 34k
5 votes

Looping every features pair with PyQGIS

the layer features = [feat for feat in layer.getFeatures()] # looping over pairs of features for pair in pairwise(features): feat1, feat2 = pair[0], pair[1] print(feat1["id"], feat2["id"]) For … in the layer features = [feat for feat in layer.getFeatures()] # looping over pairs of features for i in range(len(features) - 1): feat1, feat2 = features[i], features[i + 1] print(feat1["id" …
Taras's user avatar
  • 34k
6 votes
Accepted

Showing feature count in layer name in QGIS

single layer : # imports from qgis.core import QgsProject # getting a layer by its id layer = QgsProject.instance().mapLayer("LAYER_ID") # getting layer's name name = layer.sourceName() # counting features … looping over each layer's id for id in ids: # accessing a layer by its id layer = QgsProject.instance().mapLayer(id) # getting layer's name name = layer.sourceName() # counting features
Taras's user avatar
  • 34k

15 30 50 per page