Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

Set the Output of a script as Input of another one

What is the correct way to call the output file of a script? Since QGIS can't name it automatically. I have this script that works perfectly, just drop a file identical to the original. from qgis....
1
vote
0answers
10 views

How close an editing session in pyqgis3

I have a custom tool to add feature points. The attribute values are provided filling a custom dialog. The code was writted following this topic. At the end of the procedure, outside the tool, if I ...
3
votes
2answers
96 views

Apply a color ramp to vector layer using PyQGIS3?

I'm trying to apply a color ramp to a QgsGraduatedSymbolRenderer in PyQGIS 3 (QGIS 3.8) using the following code: Getting the QgsGradientColorRamp: myStyle = QgsStyle().defaultStyle() ...
1
vote
0answers
16 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 ...
0
votes
1answer
18 views

Refresh Oracle Layer with PyQgis

I'm working on a Dockwidget with PyQgis. I made an insert into an Oracle DB and I would like to see the new insert (it's a point). The Layer where the new point is add is URB_A_ADPT. I'm sure the ...
1
vote
1answer
27 views

Qgis 3 : QgsEditorWidgetSetup for date

I need to make a date format in QGIS 3 but, in the program I need to use, QgsEditorWidgetSetup('Date',{'yyyymmdd'}), I want to get this: But I don't know how to use QgsEditorWidgetSetup to make the ...
1
vote
0answers
15 views

Which type of slash to use in path - QGIS 3.8 with Python [closed]

I'm a beginner using Python. I had a problem loading a shapefile in QGIS 3.8 using Python, while loading a rasterfile worked perfectly. I found the solution here: Can't load a shapefile with ...
1
vote
0answers
22 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
1answer
49 views

Tab widgets in QGIS plugin - run different scripts

Is it possible to run separate python processes through tab widgets of the same QGIS plugin. I have created a QGIS plugin using the plugin builder. From QT designer I added two tab widgets to the ...
2
votes
1answer
22 views

pyqgis create layer from a list of points

I am working with pyqgis in QGIS3 and i want to create a point layer from an intersection beetween a point and a polygon layer. I can identify wich points intersects my polygon layer but i can't use ...
3
votes
1answer
35 views

Create rotated point grid inside polygon

I want to create a rotated grid inside a polygon using a starting point and a rotation angle. I have started with the python script found here. I have altered the original script to accommodate ...
0
votes
0answers
23 views

Error with minimal pluging pyqgis 3

Followed the video of the steps of this . Everything works fine, but it doesn't show the form. It gives me a mistake when callingGeometryOperationDialog().These are my files (see image)]1 This is the ...
3
votes
0answers
25 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 ...
1
vote
0answers
20 views

PyQGIS: Using variable instead of number in selectByExpression query [closed]

I am trying to select features of a layer based on an expression that uses the variable jenks_var_sep_minclass. When running it I don't get an error message, but there are also no features selected ...
2
votes
1answer
27 views

Outputting colour associated with category in text format

I've written a plugin which randomly generates fill colours for differing categories. I'm wondering if there's a way to iterate through the category renderer and output the RGB colour as text. I have ...
2
votes
1answer
25 views

Creating a Line feature in PyQGIS QGIS 3.x

In QGIS GUI, a line feature is created from this icon 1.jpg How to Create a line with a fixed distance from a vector layer in python console. This my example: from qgis.core import * from qgis....
1
vote
1answer
44 views

Pyqgis: How to use GDAL-Tool 'Rasterinfo'

I have a couple of raster layers and for my next Plugin, I want to get the corner coordinates for each layer. My idea was to use the GDAL-Tool 'Rasterinformation' which gives as an output a lot of ...
1
vote
1answer
24 views

Understanding nested list of asPolygon in PyQGIS

In Getting list of QgsPoint from polygon Layer in PyQGIS, a user explains how to get the coordinates of a polygon and gives the following code: layer = iface.activeLayer() feature = layer....
1
vote
2answers
30 views

Hiding advanced parameters in QGIS Processing Algorithm Script

There is an option, in the graphical modeler of QGIS 3.10, to mark input fields as "advanced" to hide them from user by default (advanced model parameters). I wonder how to achieve it from a Python ...
2
votes
1answer
126 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 ...
6
votes
1answer
113 views
+50

Get index of QgsAttributeEditorField from QgsVectorLayer

I have a QgsVectorLayer and right now I'm retrieving it's fields like that: for index in layer.attributeList(): print(layer.fields()[index].name(), layer.attributeDisplayName(index)) Now I ...
3
votes
1answer
38 views

Getting list of layers when opening a QGIS project on a standalone app?

I am trying to make a standalone QGIS app to read a .qgs file for rendering an image based on the vectors using LayoutManager. The problem is that when I try to print project.mapLayers() I get an ...
1
vote
0answers
19 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 ...
2
votes
1answer
38 views

PermissionError : [WinError 32] --> how to close raster file handler after use?

I created a function where I access to a Raster folder and get all files CRS for Rsubdir, Rdirs, Rfiles in os.walk(Rrootdir): for Rfile in Rfiles: ...
1
vote
1answer
52 views

PyQGIS error message: algorithm “gdalogr:cliprasterbymasklayer” not found

I wrote a QGIS plugin and at the moment I'm going through the error messages. I'm stuck on the following: Now I show you the top of my code where I import everything and the function containing the ...
2
votes
0answers
24 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 ...
3
votes
0answers
41 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", {'...
0
votes
0answers
33 views

Get catchment delineation with multiple outlets in QGIS 3.4 or 3.8

I'm starting with a DEM, then I generate a drainage direction layer (ldd). Then I'm trying to get all the watershed basins for multiple outlet points in a QGIS plugin I'm developing. I can get them ...
1
vote
0answers
27 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
1answer
21 views

Built-in ZOOM function

Does anybody know where i can find implementation of feature called "Zoom to Feature". To use this function from GUI you have to right click on layer then choose "Open Attribute Table" then right ...
1
vote
1answer
38 views

Change attribute values of multiple fields via pyQGIS

I am starting with pyQIS and I would like to change the values of two fields within selected features: from qgis.PyQt.QtCore import QVariant parent = iface.mainWindow() mc = iface.mapCanvas() myLyr = ...
3
votes
0answers
43 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 ...
1
vote
2answers
83 views

QGIS Python ImportError: No module named builtins

When I am executing a python script for doing a geoprocessing task using QGIS Desktop 3.8.3 (executed using a windows .bat file), I am getting an import error. from builtins import zip ImportError: ...
2
votes
2answers
39 views

Routing a consecutive set of points on a network

I need to generate routes based on a consecutive set of points exactly as given in this routing script by Anita Graser. As given in this image, I have a layer of consecutive points as well as a ...
3
votes
1answer
37 views

QGIS 3.8 Python merge files

For a merge operation I need a list of all my layers in the TOC with path and filename. How can I achieve that? layers = QgsProject.instance().mapLayers() # dictionary myLyrList[] for layer in layers....
3
votes
1answer
143 views

Basic script for Raster Files - PyQGIS 3

I am trying to make a script, to run at the toolbox, that receives a raster file and has an identical output to it, following the idea from here. I couldn't find a complete script that works ...
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 ...
2
votes
0answers
85 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\...
1
vote
2answers
78 views

Select features within an envelope in PyQGIS

I am trying to select (point) features within an envelope (buffer) of the start point of a line feature. I have line_layer = QgsProject.instance().mapLayersByName('DSC_Roads')[0] chainage_layer= ...
2
votes
0answers
26 views

Force virtual layer to based on layer's filter (query builder) [closed]

I have a layers, which are filtered by query builder. Next I want to create virtual layer (VL), that is based on that filtered layers. Sadly, I'm getting VL with all features from the layers. Query ...
0
votes
0answers
21 views

/{z}/{x}/{y} Template for QgsRasterLayer in PyQgis3

I took the following code which works in QGIS2 and changed QgsMapLayerRegistry to QgsProject for QGIS3. Running the code in QGIS 3.8.3, the layer is created, but the tiles do not display. The Scale ...
1
vote
1answer
25 views

QgsVectorLayer error empty

I try to develop an app using QGIS Api. My code looks like this (it's an app with a gui) : QgsApplication.setPrefixPath("C:\OSGeo4W64\apps\qgis", True) qgs = QgsApplication([], True) qgs.initQgis()...
0
votes
0answers
28 views

QgsVectorDataProvider addFeatures doesn't take attributes

I'm trying to add features in empty QgsVectorLayer with addFeatures, I got the layers without attribute: def create_features(input_file, wid, hite, focal_lgth): features = [] filename_def = { ...
1
vote
0answers
14 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 ...
2
votes
1answer
22 views

Error when creating script: QgsExpressionContextUtils not defined

This is the piece of code that is failing: ##nomenclatura = string '1.1.E.3.52' ##pdfOutput = output string from qgis.core import QgsProject project = QgsProject.instance() QgsExpressionContextUtils....
1
vote
1answer
47 views

Joining PyQGIS script parts

On my way to find a solution to This Question, I´m trying to merge some automatic generated script with This example. My thought is that after the last step, I could insert the script that does ...
4
votes
1answer
89 views

How to fix the error '_core.QgsProcessingException: There were errors executing the algorithm.'

I am trying to get the overlapping features between two layers in a loop. This works fine in most cases but raises an exception in some cases. The exception traceback does not even give any hint what ...
1
vote
0answers
42 views

Adding layers to project from a processing tool in QGIS3

I'm trying to add some layers created during a process to a project. There seems nothing to be added (TOC empty) but when I close QGIS It says: This project includes one or more layers as ...
1
vote
0answers
45 views

PyQGIS console error in QGIS 3.8.2

I have problem with python console in QGIS. Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.8\apps\Python37\lib\code.py", line 90, in runcode exec(code, self.locals) File "",...
0
votes
0answers
14 views

Build Close Vertex Finder in QGIS

In OpenJump there is a tool called ClosedVertexFinder which you can use to find vertices which are too close to each other. https://github.com/ssinger/roadmatcher/blob/master/src/com/vividsolutions/...