Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

126 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
196 views

QGIS projects in PostgreSQL (pyQGIS - saving proj to DB)

I'm currently working on some code to automate the creation of a QGIS project from tables in a PostgreSQL DB. For info I'm working in QGIS 3.4. I'm almost there, but I'm stuck on one thing How do I ...
4
votes
0answers
87 views

Rotating image by specific angle in QGIS plugin

I am using the Freehand Raster Georeferencing code in a widget to help size and locate site plans on aerial GE backdrops. I need to find a way for a user to input a specific angle of rotation and the ...
4
votes
1answer
445 views

Updating Algorithm list in pyqgis3?

I am attempting to run a union operation in a standalone pyqgis script and I'm receiving this error: Algorithm qgis:union not found The union operation fails with this code: params = { 'INPUT' ...
3
votes
0answers
27 views

How can i prevent a form from closing unless data is accepted by validation

I try to use a custom-form in QGIS 3 to validate input-data before saving the data in a database. It would be nice to have the form open unless every input is correct. But the dialog/form closes even ...
3
votes
0answers
28 views

PyQGIS Layout - Change Image Source QGIS 3

Looking for a solution to loop through existing layouts in a QGIS 3.6 document and change a source of an image. The image is the same in each of the layouts. What I have is: from qgis.core import ...
3
votes
0answers
43 views

QGIS 3.8.3 Python Ubuntu 18.04 Error : Could not load source layer for INPUT

I am running a .py file from terminal in Ubuntu 18.04. python3 script.py I am running the given below algorithm of QGIS Desktop 3.8.3 in script.py. processing.run("gdal:cliprasterbymasklayer", {'...
3
votes
0answers
45 views

Easy way to close open clipped contours with the edges of the clipping mask?

I am trying to programmatically (with pyqgis) clip contour lines that I've generated in QGIS, but make it so that the clipping mask forms the new edges of the contours, rather than leaving the ...
3
votes
0answers
32 views

Changing Map Tip popup direction dynamically

Is there a way to dynamically (or semi-automatic) change direction of a popup? Default direction is 'right-down', which in some cases, where hovered feature is at the bottom of a canvas, Map Tip is ...
3
votes
0answers
140 views

PyQGIS script crashes QGIS 3 when remove a custom pluginLayer which has custom legend

I upgrade a 2.18 plugin to 3.4. PluginLayer has been refactored and I could not create a custom legend as simple as previous major version of QGIS 2 : QgsDefaultPluginLayerLegend was removed. Use ...
3
votes
0answers
46 views

Pyqgis: Added raster layers do not show up

I have a list ("datList") with names of raster layers which I want to add. When I add raster layers in the python console everything works fine: for da in datListe: layerDir = "C:/[path]/" + da ...
3
votes
1answer
79 views

PyQGIS output to specific layer

I have a Python script that I have exported from a QGIS model and I want to specify the layer it creates as output. If defaultValue=None it outputs 'Reportpmbc': '...
3
votes
0answers
46 views

Hiding Layer Source using PyQGIS

I am developing a plugin for QGIS that loads the layers of a WFS. For security reasons I would like the user could not know the layer source. How can I remove the path of the layer in Vector ...
3
votes
1answer
92 views

PYQGIS 3 Using the ouptut from GRASS v.distance algorithm

I have a script which is trying to run v.distance on two existing shape files, buildings.shp which containing some polygons and singleasn.shp which contains a single point. This will be run from the ...
3
votes
1answer
76 views

Programmatically styling layer after output is returned from QGIS 3 processing script?

Hi this may be more of a python question rather than qgis processing script question. I've managed to successfully get the output that I want from my processing script, but I wish to take one step ...
3
votes
0answers
267 views

QGIS 3.4 Processing Python Scripts folder default configuration is lost

I have lost the default configuration of the 'Processing Python Scripts folder' on QGIS 3.4 and in consecuence some Python processing scripts and plugins cannot work properly because they cannot find ...
3
votes
0answers
537 views

PyQGIS Layout export

I have some problems with PyQGIS while generating a layout. Here is a minimal (non-)working example in which I first load some layers with their styles. Then I would like to export them using a ...
3
votes
0answers
228 views

pyinstaller package of pyqgis 3 standalone program failed import qgis.core

I have a working standalone pyqgis program with mapping ability, it was in python 2.7 and qgis 2.x library. I used pyinstaller to package it up. Now I have migrated this application to python 3.6 and ...
3
votes
0answers
252 views

“gdal:cliprasterbymasklayer” not clipping to polygons in QGIS3

I'm working on a plugin for QGIS3, and trying to clip a raster layer using a vector mask layer containing many polygons. I've been able to successfully do this using "Clip raster by mask layer" ...
2
votes
1answer
198 views

Deep Learning in QGIS: installing Tensorflow

I am trying to install tensorflow (with or without GPU support) with the keras API in the QGIS 3.4 LTR python 3 environment but without success. I do have a working install of tensorflow-gpu that I ...
2
votes
0answers
25 views

Selecting features of one layer based on another layer

I have a polygon layer A, then a new layer is created by applying minimum bounded boxes algorithm and then I selected those features in which height and width of bounded boxes is less than 150 and ...
2
votes
0answers
86 views

Integrating WinPython Spyder with QGIS?

I'm using Winpython 3.6.7 and I want to create a standalone application using QGIS 3.4.11. When I append the QGIS path using the sys module, nothing happens. import sys sys.path.append("C:\OSGeo4W64\...
2
votes
0answers
33 views

Getting layers path in Layer properties window in QGIS 3.4 by PyQGIS?

I'm going to know how I can get layers full path in table of contents in QGIS3.4 when my QGIS is closed and it's running such as daemon? Rememebr: my shapefiles are in some different folders. This ...
2
votes
1answer
74 views

Setting value to defaults Layer properties using PyQGIS 3

I have a vector layer, how to set defaults value in fields from the Python console. Layer Properties / Attributes Form / Defaults | In option: Default value |______________|
2
votes
0answers
30 views

QgsFileDownloader: download fails every time when run in a plugin

I'm developing a QGIS plugin that has the functionality to download raster files from a server. As the final step, the user has to name the file and select a file path on their system. After that, a ...
2
votes
0answers
33 views

QGIS map tile not printing some given extent in one time why?

I made a plugin in QGIS using pyqgis and qt designer to plot OSM tile in which I have one button which connects me to function in which I wrote a program to plot raster layer using param and I am ...
2
votes
0answers
46 views

How to use the Raster Calculator in PyQGIS (Console) in QGIS 3?

I want to use a script to do some raster calculations. I found this and this posts which seem to answer this question, however, it seems that they work for QGIS 2 and not for QGIS 3. I think the ...
2
votes
0answers
36 views

How to automate locally QGIS plugin building steps using exe or script?

I have made a plugin name Area Calc on my local computer. The plugin work very well. I have followed this. I don't want to release plugin. Is there any way to automate the whole above task through a ...
2
votes
0answers
30 views

How to get display of individual polygons from vector shapefile?

I am creating a shapefile with adding 20 polgons to it. poly = ogr.Geometry(ogr.wkbPolygon) for p in range(20):#20 should be replaced by pix_no ridx = rind1[p] ...
2
votes
0answers
70 views

Using Pyqgis 3 to select features from attribute table by expressions

I have a shp with the following attribute table: The column Line_ID represents each line (line 0, line 1, line 2 ... ). The column ID are the points id (point 1, point 2 … ). The column Declividad ...
2
votes
0answers
39 views

Slow retrieval of features

I have a vector layer with lots of features and I'd like to create a new layer in Python, containing only a subset of those features. To be more specific, I downloaded OpenStreetMaps data of Austria (...
2
votes
0answers
250 views

Deleting vector layer from Geopackage using PyQGIS?

Programmatically I have added the vector layers to an existing Geo Package in QGIS 3.2 using python. Similarly, I would like to delete a layer from the existing Geo package using python code. But ...
2
votes
0answers
26 views

Calling a Python function for each page in an atlas

I have made a script to do some calculations for each page of a QGIS atlas (QGIS Atlas with insert map) The script is adjusting the bounding box of a map on the layout page. To make it run for each ...
2
votes
0answers
37 views

Plugin widget, include file extension by default

I've got a Plugin widget box I'm trying to configure. In one step the user defines the path to where they will export the final layout as a .pdf file. I'm using the following code to configure the box:...
2
votes
0answers
57 views

Testing for vector joins in PyQGIS 3

I'm writing a plugin in PyQGIS 3, and I've to test for vector joins before run a code, so I've found here about vectorJoin() and write this: def joinTables(self): d, f = self.lyrPair() # d = {...
2
votes
0answers
176 views

QGIS Processing Script to Create and Add CSV Layer

I have a QGIS 3 processing script that I'm working on which has the following workflow: Get xy coordinates from a grid layer and construct a list. Make calls to the Google Distance Matrix API using ...
2
votes
0answers
115 views

Call the QGIS 3D view using PyQGIS

I am working on creating a change detection script for QGIS3, that detects the differences between two DEMs and highlights the changes. Everything is working well but I have been unable to get the 3D ...
2
votes
0answers
184 views

QGIS 3.4 Layer Properties Update Extents to minimum bounding box of features

When I use QGIS 3.4.4 on Windows 10 and right click on a layer then select Zoom to Layer I zoom to half of the earth even though the 3 items on the layer are within 50 meters of each other. I tried ...
2
votes
0answers
125 views

QGIS 3.x closestSegmentWithContext returns sqrt distance 0.0 and point doesn't snap to polyline

I have a point and line shapefile. I am new to QGIS and Python, but have been able to get a working method to snap some of the points to the line. The method I am using is "closestSegmentWithContext",...
2
votes
0answers
59 views

Is there a way in PyQgis to perform a transaction upon several features at once for undo and redo operations?

I'm developing a standalone application in pyqgis (python 3.6, qgis 3.2) for editing roads and ran into a problem connected to performing transactions. When the user of the app insert, update or ...
2
votes
0answers
98 views

Convert QgsVectorLayer.extent() to EPGS:4326

Many APIs such as overpass turbo require bounding box notation like (x_max, y_max, y_min, x_min) in EPSG:4326. However the method QgsVectorLayer.extent() returns values in the source's CRS. A possible ...
2
votes
0answers
175 views

Refactor Fields using PyQGIS3

I am trying to use Processing tool to automate refactoring for several tables: here is the code I am trying to use import processing input = 'C:\\Users\\Ehsan\\Desktop\\CIS WORK\\Sample files\\...
2
votes
0answers
40 views

How to impose constraints on drop lists of two fields of the same layer?

Is it possible to impose with pyqgis3.0 some constraints on a drop list of a field attribute in order to govern the drop list attributes of another linked field? To better clarify this issue, I attach ...
2
votes
0answers
79 views

Changing the Location of Python Expressions QGIS3

I've recently started using QGIS and I've written a few custom functions to use with expressions in the Function Editor (see image below) From what I can find these appear to be saved in: C:\Users\...
2
votes
0answers
111 views

Saving outputs of “proccesing” to temp file in PyQGIS

I'm trying to save the output of a "proccesing" algorithm executed in PyQGIS as a temporal file, and then re-using it with another algorithm. The desired result is to write the output only at the end ...
2
votes
0answers
762 views

Python processing script with clip in QGIS 3.2

I have been following the QGIS scripting templates, but have been unable to get vector processing to work with input and output layers. Working with QGIS 3.2.2. The following script is my attempt at ...
1
vote
0answers
28 views

PyQGIS grass7:v.distance parameter error “The number of columns and the number of upload parameters should be equal!”

I am currently working on a Python script for QGIS in which I would like to obtain the (minimum) distance from each point (polygon centroid) in the points layer centroid_layer to the line layer ...
1
vote
0answers
23 views

Rotating raster cells with QGIS GDAL

I've written a PyQGIS script based on this answer to the following question: Writing numpy array to raster file My data shows up at the correct, expected location but the raster cells, which are ...
1
vote
0answers
20 views

Add help tab in plugins from the toolbox

Is it possible to add in QGIS 3 (Python Script) a help tab on the plugins created for the toolbox as it was in QGIS 2? Looking in the API I found the parameters helpString that will be deprecated in ...
1
vote
0answers
28 views

PyQGIS wrong editing tool warning

I am trying to add a point by using the pyqgis code below: layer = iface.activeLayer() # point layer layer.startEditing() iface.actionAddFeature().trigger() Then the marker becomes add feature ...
1
vote
0answers
15 views

PyQgis 3 Script for PDF Exporting not showing map?

Im writing this script for exporting PDFs, I managed to get an output PDF as I wanted but its not showing the Map window. If i get into the Composer, the map is blank but magically refreshes and shows ...