Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

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

Pyqgis import non-spatial CSV to Qgs project

I'm trying to upload a .csv file to my QGIS project via Pyqgis. According to the following thread Using non-spatial CSV with PyQGIS it should work that way: uri = 'file///C:/Users/denni/Desktop/test....
1
vote
0answers
23 views

Using QGIS plugin that's designed for use in interface within PyQGIS?

I need to use a plugin that's designed for use within the QGIS interface in PyQGIS. For example https://github.com/dgoedkoop/joinmultiplelines works great but I want to run it within a script, so ...
1
vote
0answers
37 views

PyQGIS replace text label in Layout view by new text label from csv tabel

Currently, I'm stuck working on my first python plugin and hope to get some adivce here. The plugin should take a csv file (or .xlsx would be even better) which has two string columns. Column 1 has ...
2
votes
1answer
50 views

In PyQGIS can I get the total length of a road where it's broken up into segments?

In PyQGIS can I get the total length of a road where it's broken up into segments? In SQL I would run SELECT format_number(ROAD_ID,0) as Road_ID, ROAD_NAME as Road, format_number(Sum(st_length(...
1
vote
1answer
43 views

PyQGIS update field in line dataset when it is within a polygon

I am trying to update a field in a (Road centerline) table based on a value from another table when it is within a Polygon (Locality boundaries). Based on posts like QGIS layer.geometry.intersection()...
1
vote
1answer
29 views

PyQGIS changeAttributeValue not saving modified records

I've been trying to save some changes to the a dataset using PyQGIS but I can't see any changes even after closing/reloading the layer attribute table. I have tried a few different options but none ...
3
votes
1answer
239 views

Change vector layer symbology PyQGIS 3?

I'd like to change the symbology of my vector layer and can't figure it out how to read the documentation. I would like to have an polygone with an orange outline, a dashed fill style and an orange ...
3
votes
2answers
126 views

Renaming the result of a QGIS Processing Algorithm

When calling a QgsAlgorithm from within another, the result will be named after this algorithm output regardless of what is setup as the output of the main one. For instance, taking the code from ...
1
vote
1answer
174 views

Exporting map to PDF from template using PyQGIS?

I'm trying to update a QGIS plugin to PyQGIS 3 but I have some troubles to update the code for exporting layout to PDF. The layout derives from a template file. This is the "old" code: canv = iface....
1
vote
1answer
74 views

QGIS 3.4.2 on Windows: pyqgis 3 rule-visibility depending on scale

I have a plugin for QGIS 2.18. In QGIS 2.18 it was possible, to toggle the visibility of each of the 7 "sublayers" (see below) by python-code: symbol = QgsMarkerSymbolV2.createSimple({'name': '...
2
votes
1answer
78 views

Feature is snapped?

I try to detect, if a newly created feature is snapped according the snap options: def isSnapped(self,feat): try: snapper = QgsSnappingUtils(self.iface.mapCanvas()) snapper....
1
vote
1answer
39 views

Changing Layers Attributes in pyqgis

I am trying to change the attributes of a table in pyqgis. However, when finishing the changes, I cannot see them in the layer. I am using QGIS 3.8.1 Here is the simple version of my code layer....
3
votes
1answer
133 views

Get Layer's Raster Band Data in pyQGIS

In QGIS I am trying to read raster band data from a specific layer in my Python plug in. I can easily get access to the layer from the console with something like this. iface.mapCanvas().layers()[0] ...
1
vote
0answers
32 views

Issue with writing virtual layer as CSV in PyQGIS [closed]

I am trying to figure out why I can't write a in memory virtual layer to the file system. The folder exists QgsVectorFileWriter.writeAsVectorFormat(vlayer, r'c:\temp\xyz.csv', "utf-8", None, "CSV") ...
2
votes
1answer
92 views

Multipart geometry after pyqgis-3 intersection()

I'm trying to intersect two polygons with intersection() function of QgsGeometry (pyqgis-3). The problem is that the result is a multipart polygon instead a single part polygon and QGIS doesn't allow ...
2
votes
1answer
114 views

QGIS 3 export report in Python

In QGIS we have new layout type: Report. I didn't find tutoral to export this in PDF in Python. Where can I find Python code examples?
3
votes
0answers
162 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 ...
1
vote
1answer
77 views

Format Query statement for use in Virtual Layer query from PyQGIS

Based on QGIS: SQL query within python console to sum a column based on values of other two columns I am trying to write a script that will get the field names to use from PyQGIS but am having issues ...
1
vote
1answer
40 views

pyqgis 3 vector layer labeling settings dialog

I am working on a pyqgis standalone application with the latest QGIS 3 libraries and in python 3.7. I would like to allow users to modify any vector layer's labeling style, I know in QGIS program, one ...
1
vote
1answer
65 views

Showing attribute table in QGIS plugin

I'm trying to develop a plugin which grabs a layer from the project and shows its attribute table in a tableView. My code is as follows: def getVectorLayer(self): layer = None layername = ...
1
vote
1answer
62 views

Specifying the parameters for processing function qgis:joinattributestable with PyQGIS-3

I would like to join a CSV and a vector layer, based on a field. I know I can handle this with multiple lines like in first part of https://www.qgistutorials.com/en/docs/performing_table_joins_pyqgis....
2
votes
1answer
63 views

Adding QgsLayoutItemTextTable to a print layout

I am writing a script that automatically generates a print layout. In addition to the map, the print layout should contain a table with results of a series of calculations that I have in the form of a ...
1
vote
0answers
27 views

Configure QGIS in a project on PyCharm on Ubuntu

I'm creating a PySide2 project and i'd like to know if it's possible to add QGIS in it. When i puted "from qgis" it does not work. from PySide2 import QtCore, QtGui, QtWidgets from qgis._core import ...
2
votes
1answer
118 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
1answer
21 views

Reading default qgis-auth.db from a script

I try to read username and password from the qgis-auth.db, the latter having been configured under QGIS (3.6.1, Ubuntu). Here is my code : import os import sys from qgis.core import QgsApplication ...
1
vote
2answers
273 views

Algorithm not found by PyQGIS?

I have troubles using PyQgis processing module with QGIS 3.8. For example, I can reproject a layer with QGIS graphic interface, but when using PyQgis processing module through the following script : ...
1
vote
1answer
256 views

PyQGIS 3 Set Svg marker symbol

I would like to add my own SVG symbol instead of a dot. I tried the following. layer = iface.activeLayer() QgsProject.instance().addMapLayer(layer) svgStyle = {} svgStyle['fill'] = '#0000ff' ...
2
votes
0answers
34 views

getFeatures() delivers some fields more multiple times

I am extracting data from selected fields using .getFeatures() in PyQGIS (see code below). The result is correct, but for some reason python delivers some features multiple times (see below; Lamu ...
4
votes
1answer
155 views

Show feature count with PyQGIS 3

After adding a layer to my QGIS project with a Python script, I want to show the number of objects beside the layer in the layer window. I have tried this code, which is from Show feature count of ...
1
vote
0answers
89 views

Calling a temporary layer in PyQGIS

I have the following PyQGIS script (see below) which works fine except from one issue: The input vector layer I would like to use is a temporary file. How can I call a temporary layer (which does not ...
1
vote
1answer
51 views

PyQGIS error when running zonal statistics?

I want to extract the sum of my raster cell values with a specific area through zonal statistics and have prepared the following code (see below). When I run the code I get the following error message ...
1
vote
1answer
89 views

Buffering point using PyQGIS?

I have made an attempt to create a buffer around some points useing PyQGIS. However, when running the following code (see below) I receive and IndexError saying that 'list is out of range'. What ...
1
vote
0answers
82 views

Syntax error using layer.getFeatures PyQGIS

I am simply trying to run a command in QGIS to extract the coordinates of a point layer, but I get a syntax error when trying to do so (see code below). I can not see where the issue is - any ...
3
votes
0answers
52 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 ...
2
votes
1answer
100 views

How can I make use of the QGIS authentication manager in PyQGIS processing scripts?

I have developped a set of QGIS processing scripts that rely on some background data stored in a postgreSQL database. During my development phase I had the database on my localost server and connected ...
2
votes
0answers
32 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
35 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 ...
4
votes
1answer
89 views

Why get the first and the last point code from a multilinestring layer in PyQGIS 3 doesn't works?

I need to get the first and the last vertex from a multilinestring layer from PostGIS and create a memory point layer with them. The code below works for some line layers and doesn't for others in ...
2
votes
1answer
190 views

Change Stroke Style of a Simple fill Symbol Selector with PyQGIS

How do i change the Stroke Style of a simple fill with python ? Here is a picture that i want to change ? Here is my code : processing.run('native:buffer', {"INPUT": delta, "DISTANCE":...
3
votes
1answer
101 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': '...
1
vote
0answers
53 views

Use pyQGIS to extract QGIS style as geometry in a DXF

I have a qgis point layer with a complex data driven style: This is the style without other layers: When exporting the layer as Dxf I would like to also export the style so the symbols are visible ...
3
votes
1answer
112 views

Setting a Background Color with RVBT field with python

I'm trying to set the color of a background of a layer. To do this i created an attribute "Color" with the RVBT numbers associate to each feature. As in the picture, i want to set the color with those ...
2
votes
1answer
191 views

PyQGIS standalone app with pycharm : exit code -1073741819 (0xC0000005)

I try to run standalone PyQgis code with PyCharm, but I always have this result : Process finished with exit code -1073741819 (0xC0000005) I tried my code line by line, and this result appear after ...
2
votes
0answers
64 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
1answer
265 views

Loading print layout using an existing template (.qpt) with PyQgis3

I'm trying to load a print layout (.qpt) which I saved earlier via PyQgis. I found this earlier entry, but it's for QGIS 2.x and thus doesn't work for QGIS3: Programmatically load composer from ...
0
votes
2answers
61 views

Transforming time series gridded meteorological data from .csv file to multiple .shp files (one per date) with pyQGIS

I downloaded gridded meteorological data as .csv file from the JRC CGMS database for a territory of interest. The file has data for predefined point locations over the territory in a regular-spacing ...
1
vote
0answers
164 views

How to build loop using memory layer with PyQGIS 3?

I have a "for" loop included on a "while" loop, and it work when I save the for loop result in a shapefile and I reuse it on the loop like that : #last step of the "for" loop alg_params = { ...
3
votes
1answer
86 views

Saving raster layer to disk using Python: TIFF raster layer loses data type when saved with QgsRasterFileWriter

I'm trying to save a TIFF image stored as a raster layer. The image is fetched from a server so that its source (the url passed when creating the layer) is a HTTP url: the image should be saved to ...
1
vote
1answer
110 views

Setting Layer rendering Blending Mode of Feature using Python

I'm trying to set the blending mode of a layer like on the picture, Darken on Feature, not on layer, with Python. Here is the code that i used to modify the "Layer" Blending mode. layer=iface....
2
votes
0answers
42 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 ...

1 2 3 4 5 9