Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

Filter by
Sorted by
Tagged with
1
vote
1answer
23 views

Acessing fields of created features in your PyQGIS

I'm new using PyQGIS 3 and I'm wondering how to access the field information from a layer generated by script. inside my processAlgorithm function I have the following: alg_params = { '...
1
vote
1answer
18 views

Standalone script creates unwanted directories

I use the following code to import the relevant modules and prepare for a standalone script for QGIS 3.14: # Import modules import sys from qgis.core import QgsApplication from qgis.analysis import ...
0
votes
0answers
30 views

Accessing input layer when using “Selected features only” returns 'NoneType' object in QGIS 3 processing script

I am trying to write a processing script in QGIS 3.10.8 which would execute database function based on the selected features (or their id). I defined the input in a way that it accepts a point vector ...
1
vote
1answer
31 views

PyQGIS selecting features by mouse click

I am following a tutorial where I am trying to learn how to use PyQGIS to programmatically accept a user's feature selection from the map canvas of QGIS by mouse click. I have encountered a problem ...
1
vote
1answer
33 views

Save CSV with separator using PyQGIS 3?

I need save selected attributes of layer as CSV with separator. This is my code: def initAlgorithm(self, config=None): self.addParameter(QgsProcessingParameterVectorLayer('Input', 'Input', ...
0
votes
0answers
21 views

Custom logic inside processAlgorithm and accessing input parameters [closed]

I am fairly new to QGIS and I am not sure if I can write custom logic inside processAlgorithm. I have created a custom form and taking input but I am not sure if I can access them to create a new ...
1
vote
1answer
54 views

Coordinate Transformation Difference between QGIS and Proj

I transformed coordinates on PyQgis and Proj command line and there is 3.8 meters difference between the transformations. I used the same EPSG codes. For Proj 6.3: echo 35.53 38.75 | cs2cs +init=epsg:...
2
votes
1answer
26 views

Counting intersections between two line layers using pyqgis

I want to count intersections between two line layers using pyqgis. First layer connects two points (Memorylayer_VL / Connections), the second one represents streets (lines_layer / Streets). I need to ...
1
vote
0answers
30 views

How to receive input name by script in the toolbox on QGIS 3.14?

In QGIS 3.4.7 I have a script that I use in the toolbox and one of the steps is to store the name of the input tiff in a variable. I accomplish this perfectly with this part of the code: from qgis....
1
vote
0answers
83 views
+50

Zonal statistics for multiple rasters with overlapping polygons

I have a shapefile with 300 polygons that correspond to 300 rasters (the rasters have the exact same extent than their corresponding polygons). What I'm trying to do is to run Zonal Statistics on this ...
0
votes
0answers
17 views

QGIS crashes when intercepting QgsVectorLayer.featureAdded event and user decides to Toggle edit mode off

I am quite new to QGIS and Python plugins. I have the following code in my plugin def feature_added(fid): # GET INSTANCE OF NEWLY ADDED FEATURE feature = my_layer.getFeature(fid) # ...
0
votes
1answer
20 views

Programmatically press the “select all” button in WFS capabilities of QGIS project properties with Python

I would like to ask if someone knows a way to press the "select all" button in Project>Properties>QGIS Server>WFS capabilities using python, or if is there a specific command to do ...
0
votes
1answer
21 views

Why is scale of image different in QGIS 3.10 than created?. CAD import and twf world file seems correct

I created an image by taking a picture of a tape measure(ruler). I rotated this image to north and made a world file .tfw for the tiff image. to get the pixel width for the twf file, I divided the ...
1
vote
1answer
67 views

Changing features of vectorlayer using PyQGIS

I am working on a QGIS plugin for which I am iterating over an inputlayer (point) and requesting a responselayer (polygon) for each inputfeature. The responselayer then contains several ...
0
votes
0answers
31 views

Qgis Dialog Not showing any Qwidgets Why?

i tried call another dialog form qgis plugin its show the dialog but not showing any Qwidget in that file how to show them (if i call single ui file its showing fine ) Qgis Plugin Code: from qgis.PyQt....
0
votes
0answers
16 views

Why does QGIS fail to include authentication manager overlays when using standalone exportToPDF?

I have an existing layout and I'm trying to export it to PDF from a standalone script after the data is updated automatically. If I open QGIS and export all is good but when I call it from Python I ...
1
vote
1answer
38 views

Layer selectByExpression is Not select any feature even Expression is right why?

I am trying select the features by expression if i pass query as string its working but if pass variable is not return any result why. WORKING CODE InputFeatureLayer.selectByExpression("\"...
0
votes
1answer
29 views

Writing the table layer_styles in a Geopackage

I made a pyQGIS script to backup the PostGIS tables of my team. I needed to save each table style in the Gpkg's layer_styles. Here's an extract of how I've done but I would prefer to implement the ...
0
votes
1answer
45 views

QGIS 3.10.8 Add features and attributes to exisiting layer using python

Is there a way to add features from one layer to another while matching attribute names using Python? Using QGIS 3.10.8 I am trying to add features to an existing layer. I have been using the code ...
1
vote
1answer
45 views

How can I adjust the zoom level and recenter in QGIS automatically?

I am using QGIS 3.14 and the Python console (pyQGIS). I will be tracking a line from GPS co-ordinates and I want to be able to adjust the screen and zoom level accordingly. Here is my code: canvas=...
0
votes
1answer
27 views

gdalnumeric.LoadFile() with temporary output from QGIS algorithm

I'm trying to access a previously created temporary raster output with gdalnumeric.LoadFile() to calculate some statistics. It seems to me that gdalnumeric.LoadFile() can only access a file through a ...
1
vote
1answer
72 views

Query list of layers an run code on each layer

I want to query all opened layers in my QGIS project and then run an algorithm on each of the opened layers. layers_list = [] layers_list = QgsProject.instance().mapLayers().values() name_field = '...
2
votes
1answer
64 views

Using SAGA tool in PyQGIS standalone script. Output doesn't return vector layer

In my standalone script I want to use the SAGA tool "merge vector layers". According to the docs I need the following. Thus, I wrote the following code to implement the tool: def merge(self):...
1
vote
0answers
16 views

Saving attributes information (features) in QGIS layer

I have a road network (lines) and points (Address). I am using PyQGIS to join points to the nearest lines using the closestSegmentWithContext functionin QGIS. However, the attribute table of ...
0
votes
1answer
23 views

Load a table with NO geometry_column using PyQGIS

I had to backup a PostGIS model in a geopackage and I wonder how to load a non-spatial table, aka a table with NO geometry_column.
3
votes
1answer
52 views

PyQGIS Temporal Controller current moment

I have a QGIS Project with Temporal Controller, in Python Console. How could I capture the current moment of the simulation? I'm trying, but doesn't work canvas = iface.mapCanvas() temporal= canvas....
0
votes
0answers
22 views

How to initialize the QGIS from standalone script?

I tried to initialize QGIS from a standalone script, but it's giving the error (find in an image). I reinstalled, but the same issue occurred. code: from qgis.core import * QgsApplication....
2
votes
1answer
31 views

How to export a table in a geopackage

I'm trying to export a simple PostGIS table loaded in QGIS to a geopackage file. Here's an example: options = QgsVectorFileWriter.SaveVectorOptions() options.driverName = "GPKG" options....
0
votes
1answer
19 views

GDAL Driver from QGIS 3 Raster Layer

How do I use python to find raster layer properties like The GDAL driver and/or description used to load a raster in QGIS For Example : for a Tif 'GTiff' and 'GeoTiff' or        for an ESRI Grid '...
0
votes
1answer
27 views

Qgis getting crashed on Update Feature Signal

Like ArcGIS Editor Tracking, I am trying to design attribute field with self update date feature called Updated Date in Qgis. I am following Making automatic updated date and time field in QGIS this ...
2
votes
1answer
35 views

Programmatically removing Annotation items crashes QGIS 3.10

I'm writing a plugin (based on Plugin Builder 3 "tool button with dialog") to allow complex annotation in QGIS 3.10.5, and whilst I can add annotations OK, as soon as there's more than one, ...
1
vote
1answer
22 views

Check if polygon intersects with coordinates in a .csv file with PyQGIS standalone script

I have a bunch of .csv files with coordinates and a polygon. In my standalone script I would like to check if the polygon intersects with the coordinates. So, when I write: for feature in ...
0
votes
0answers
19 views

Display InSAR calculation results on satellite images

I have used PSInSAR technology to process and got the result of ground subsidence velocity. I saw in [a paper]1 that the results of ground subsidence velocity (a layer) can be displayed on satellite ...
0
votes
0answers
22 views

How to loop GDB in PyQGIS? [duplicate]

Hi I am new to python Qgis. i have gdb that contain feature class.i'm trying to get those feature classes into pyqgis but how to loop Gdb? please provide some samples Thankyou.
0
votes
1answer
26 views

Get data type for a QGIS 3 RasterLayer

How do I use python to find raster layers data type The raster data type for a band like float32 or int16? I know you can use rasterlayer.dataType(1) but how do I then lookup returned integer (eg 6) ...
0
votes
0answers
22 views

After start editing, the editing toolbar remains inactive in QGIS

With respect to my previous question Disconnect editingStarted in PyQGIS , While doing some research for question, I found some details to stop editingStarted signal with following code. layer=iface....
1
vote
1answer
19 views

How can I set the default layout export resolution in pyQgis?

I want to change the default export resolution (default value = 300 dpi) programatically when I open the layout designer l = QgsPrintLayout(project) l.initializeDefaults() l.setUnits(QgsUnitTypes....
0
votes
2answers
67 views

How to resample a raster considering a minimum number of valid pixels

I'm looking for a function to resample a raster that can consider a minimum number of valid pixels in order to compute the new pixel value. E.g. If I have to resample a raster of 300m/px to 1Km/px I ...
3
votes
1answer
82 views

Aggregate attribute based on symbology classes in QGIS

I was wondering if there is an existing tool/way to aggregate an attribute based on the active symbology of a layer. For instance, if I have a point layer with population and distance from the city ...
0
votes
1answer
12 views

PyQGIS Turn on panel not working once inside class (QDockWidget)

I am relatively new to PyQGIS and struggling to convert my simple code into a plugin class. The code works when run from the Python window, but when I add it to def run(self): I get an error, which I ...
0
votes
1answer
58 views

Disconnect editingStarted in PyQGIS

I am creating a Plugin, where on addFeature button, first user will get a dialog box to select the type of feature user wants to draw. On the basis of users choice, other editing constraints will get ...
0
votes
0answers
16 views

Getting currentfeature's color in Expression Builder of QGIS 3.xx

I want to obtain the color code of the current feature like this : Getting currentfeature's color in Expression Builder of QGIS? But I am in QGIS 3.14 and I dont understand how to convert the ...
1
vote
1answer
70 views

How to change a line Symbol layer type using PyQGIS? [closed]

enter image description here I need to change a line style from Simple Line to Marker Line, and after that, use it as an arrow and change it's rotation and colors using PyQGIS.
1
vote
1answer
53 views

Deleting style categories in QGIS3 leads to incorrect feature count

If I use PyQGIS to delete style categories of a layer the feature count gets messed up: Before deleting the category (style class) "3x20/15mm /VL" the featurecount shows 1 feature which is ...
3
votes
0answers
36 views

Selecting features by current map extent in QGIS 3

I'd like to select all features in the current map extent that also satisfy some other condition via "Select by Expression". For instance I'd like to do something like this: intersects($...
0
votes
0answers
17 views

Automatic map export but QgsLayoutItemLegend not display in output

I want to export my map from Qgis3 in .png but the legend is not display on my output. Title of the legend is display so the layout work and is at the right place but layers with symbols are not ...
2
votes
0answers
47 views

Creating line geometry from latitude/longitude dictionary

I want to create LineString geometry between points, based on a latitude/longitude dictionary. My code worked in QGIS 2.x but in QGIS 3.x, my new shapefile is empty. I have replaced QgsPoint and ...
2
votes
1answer
32 views

PyQGIS & Qt - Revisiting the 'dialog window on top' issue

I want to keep a modeless dialog window on top of the main QGIS window. This issue has been discussed before and two solutions have been offered: self.dlg.setWindowFlags(Qt.WindowStaysOnTopHint). ...
0
votes
0answers
42 views

Deleting shapefile python (lock?) (QGIS 3.10)

I have trouble with deleting shapefiles and notice a weird behavior when I am running my scripts layer = QgsVectorLayer(path_layer, "name_layer", "ogr") cloned_layer = clone_vl(...
2
votes
2answers
40 views

Call a QgsMapToolIdentifyFeature mapTool with a button in a QGIS3 plugin

In QGIS 3.12, I'm trying to get a feature on the mapCanvas from a plugin trough a pushButton. I used the code from here but it doesn't work in the plugin although it works fine in the QGIS python ...

1
2 3 4 5
12