Skip to main content

Questions tagged [qgsfeaturerequest]

QGIS API class to request for features to a vector layer.

Filter by
Sorted by
Tagged with
3 votes
1 answer
118 views

Fetching only ids of features with QgsFeatureRequest in PyQGIS

Using a QgsFeatureRequest by default will fetch all attributes (including geometry) of the features. I can use .setFlags(QgsFeatureRequest.NoGeometry) to not fetch the geometry, and ....
persephone's user avatar
1 vote
1 answer
64 views

PyQGIS layer action: Select features within buffer having the same field value

By means of a PyQGIS layer action, I am looking for a way to select all polygon features within a buffer polygon sharing a certain field value (e. g. provinces belonging to the same country) with the ...
ebcs's user avatar
  • 49
1 vote
1 answer
472 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 ...
Matt_Geo's user avatar
  • 1,050
2 votes
1 answer
84 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 == ...
MrXsquared's user avatar
  • 34.9k
4 votes
1 answer
340 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 ...
Suzanna Cuypers's user avatar
3 votes
1 answer
204 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 ...
Peter's user avatar
  • 173
0 votes
1 answer
119 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 ...
Kareem Alaraby's user avatar
2 votes
3 answers
1k 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:...
V Damoy's user avatar
  • 389
1 vote
0 answers
343 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 (...
Francisco Camello's user avatar
4 votes
1 answer
480 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"] ...
EnGIsNowhere's user avatar
1 vote
1 answer
285 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 ...
Kajo's user avatar
  • 691
2 votes
1 answer
393 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 ...
strythe's user avatar
  • 587
1 vote
0 answers
212 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]) + ' ...
Chris's user avatar
  • 111
1 vote
1 answer
250 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 ...
applebrown's user avatar
3 votes
1 answer
315 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 ...
applebrown's user avatar
7 votes
1 answer
3k 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,...
dmjf08's user avatar
  • 1,293
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? ...
Jose's user avatar
  • 218
1 vote
1 answer
124 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] ...
Marcel Campion's user avatar
2 votes
1 answer
400 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 ...
Guoooo's user avatar
  • 75
1 vote
0 answers
89 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- ...
For Comment's user avatar
  • 1,115