Questions tagged [qgsfeaturerequest]
QGIS API class to request for features to a vector layer.
18
questions
1
vote
1
answer
270
views
Using the "Selected Features Only" checkbox with QgsProcessingParameterFeatureSource in PyQGIS script
I'm working on a custom QGIS Processing algorithm, and I'd like to include an option for the user to process only the selected features in the input layer by using the checkbox "Selected Features ...
1
vote
1
answer
58
views
Requesting features where expression result equals a given variable
I want to get the features of a layer, where the evaluated expression equals an already evaluated expression. Can I somehow do this directly using layer.getFeatures(QgsFeatureRequest(expr == ...
4
votes
1
answer
248
views
"Could not load source layer for MASK: invalid value" error when iterating over features in polygon layer and clipping raster by mask layer in PyQGIS
I have just started using PyQGIS and need to loop over parcels in a vector layer to clip a raster layer.
For each parcel, I want to generate a .tif file with the feature.id() in the filename. I will ...
3
votes
1
answer
172
views
Finding lines with length of 0.0 inside polygon with Python script in QGIS
I have a vector layer (PostGIS) with line geometries. Some of these geometries have a length of 0.0, but they have two points with the same coordinate.
I want to handle this features within a python ...
0
votes
1
answer
110
views
Requests Python module in QGIS return nontype or empty CSV
I am using the Requests Python module to query a 3rd party API that returns a polygon of an address, the returned CSV returning only part of the header, while it is working fine when using the code ...
2
votes
3
answers
772
views
Adding and filtering layer with map canvas extent using PyQGIS
I'm creating a small QGIS3.16 plugin with PyQGIS.
I'd want to add a vector (PostGIS) layer to QGIS, and immediately filter it with the QGIS canvas extent.
I found the QgsFeatureRequest(rectangle:...
1
vote
0
answers
281
views
How can I made requests (QgsFeatureRequest) or selections (selectByExpression) from a list of QgsFeature?
I've got a processing algorithm that does a request to select some features that correspond to the incorrect filling of the attributes. It reads a JSON file containing a description of expression (...
4
votes
1
answer
341
views
How to select specific fields using getFeatures() without getting all of them in QGIS-3.10
So I'm trying to convert code from ArcGIS to QGIS. The part I am at right now is converting:
lst_fields = ["full_id", "osm_id", "osm_type", "boundary", "is_in", "leisure", "name", "type", "landuse"]
...
1
vote
1
answer
241
views
Printing how many features satisfy a QgsFeatureRequest (QGIS 3)
I have a QgsFeatureRequest() that filter all the features by an attribute.
Is there any python function that could tell me how many features were filtered?
I know I could create a list with this ...
2
votes
1
answer
364
views
How to use the ExactIntersect flag for QgsFeatureRequest() object
I have two layers, a polygon_lyr and a line_lyr. I want to use a QgsFeatureRequest() for the line_lyr.getFeatures() but instead of returning the lines which intersect the bounding box of a polygon, I ...
1
vote
0
answers
204
views
QgsFeatureRequest() with a string search within QGIS3 Processing Script [closed]
I'm trying to select features using a string comparison within my script using a QgsFeatureRequest() and getFeatures()
roadsRequest = QgsFeatureRequest()
roadsExpression = str(roadsIDField[0]) + ' ...
1
vote
1
answer
237
views
QGIS 2.18: Filter line-layer by QgsExpression
I have a line layer on which I want to run a filter within a python script.
I am trying to achieve this via QgsExpression and QgsFeatureRequest.
Below you see the same filter that I want to apply in ...
3
votes
1
answer
287
views
QGIS 2.18: Speed up QgsFeatureRequest in Python Script
I have two input layers. The first one is a line-layer named "graph" and the second one is a point-layer named "nodes".
The "graph"-layer:
The graph layer holds 177350 line features which are ...
7
votes
1
answer
2k
views
'Could not load source layer for INPUT: layer not found' error when running QGIS algorithm on selected features using PyQGIS
I try to run algorithms on layers but only on selected features with QgsProcessingFeatureSourceDefinition() in a loop and then write the result with QgsVectorFileWriter:
layer1 = QgsVectorLayer(path1,...
8
votes
1
answer
2k
views
Running QGIS algorithm with selected features from layer using PyQGIS
In the QGIS GUI, the select-by-location algorithm has a choice to only use the selected features from the INTERSECT layer. How can I do this (or use any other algorithm) in a python script for QGIS 3?
...
1
vote
1
answer
117
views
QgsfeatureRequest - Store result indexes
I recently posted a question. My original goal was to find a way to determine on which side of a line points are located. @xulnik answered this question with two codes. One returns a binary [0;1] ...
2
votes
1
answer
381
views
How to refresh a layer after filter features in pyqgis
When I queried some features using QgsFeatureRequest().setFilterExpression() in pyqgis,I want to make the current layer just only show what I queried without creating a new memory layer. Just like you ...
1
vote
0
answers
80
views
How to set flags when re-use QgsFeatureRequest object
I have a standalone PyQGis application that is working fine. When I query a vector layer via QgsFeatureRequest class, I would like to instantiate one object and reuse it. But I am not sure how to set- ...