Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 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
26 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
36 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 ...
-1
votes
0answers
29 views

Mapping large shapefiles with R? [closed]

I have a large shapefile (134MB), which I am working on in R. I want to generate an interactive map of this, something along the lines of tmap or leaflet. The trouble is, every tool I have tried ...
0
votes
0answers
29 views

Deleting shapefile and related extension files from folder when not in use

I have to delete two shapefile layers from my folder. I use these shapefiles to run processing Algorithms after which i want to delete them. The code I use use is as given below. for filename in os....
2
votes
0answers
26 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 ...
1
vote
0answers
15 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
62 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
21 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":...
1
vote
1answer
47 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
39 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
40 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
35 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 ...
1
vote
0answers
22 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
29 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
49 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
35 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 = { ...
1
vote
0answers
28 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
24 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
25 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
1answer
25 views

Using splitGeometry in PyQGIS

Using QGIS 3, I'd like to split a polygon using a line. My inputs are .geojson files, but that should be irrelevant: Line: { "type": "FeatureCollection", "name": "line", "crs": { "type": "name", "...
2
votes
2answers
60 views

Setting Buffer from GeoprocessingTools with a feature

I'm trying to set up a Buffer from Geoprocessing Tools and i would like to put a Field from the layer as Distance Souce. Here is my code : import processing layer = QgsVectorLayer(path_to_routes, ...
2
votes
1answer
43 views

How to change page orientation and number of pages of print composer layout using pyqgis in QGIS 3.4?

I am writing a qgis layout script to export my results in a pdf. I am using the tutorial provided here but this tutorial do not teach how to turn the page orientation from landscape to portrait. my ...
0
votes
0answers
17 views

Loading layer with QgsVectorLayer in standalone PyQgis 3

I can't seem to figure out why my layer won't charge in QGIS. After reading many topics, it seems to be linked to the prefix path. However changing this, does not seem to work (I tried around 10 ...
1
vote
1answer
29 views

How to use 'memory:name' output as VectorLayer in PyQGIS?

After running processins in a loop, I try to export results on a single shapefile. I've created a vector layer called "regroupee", I merge results with it, and I overwrite "regroupee" with the result....
1
vote
1answer
51 views

Setting placement labels on “Offset From Point” with OffsetX,Y parameters in PyQGIS?

I'm trying to set properties of QgsVectorLayer using QGIS 3. I want to put labels with "Offset from point" and define "Offset X" and Offset Y". I saw on the documentary that there is a class "...
2
votes
0answers
22 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] ...
4
votes
0answers
36 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 ...
1
vote
1answer
64 views

How do I access stroke color and width of a simple marker with python in QGIS?

I'm trying to set up style properties of a vector layer using python. I was able to modify the marker properties but I cannot modify those of Simple Marker, like width or color. Here is my code : ...
1
vote
0answers
37 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
1answer
26 views

How to Batch Export Visible layers / layers in a preset using PyGIS

I would like to save all layers that are part of a preset in QGIS to an external folder using Python I have got the following code from another question from qgis.core import * suffix = "_Test_save"...
2
votes
1answer
70 views

Interface of QGIS plugin created by QtCreator

The image below is the interface of the plugin which I created using Qt Creator. However, when I loaded this plugin in QGIS3 (version: 3.6.1). The interface of the plugin does not appear completely. (...
2
votes
1answer
38 views

Getting label quadrant using PyQGIS?

How can I get the specified quadrant of a label using PyQGIS? The print statements below return 1 and 0 no matter which option I pick in the dialog. palyr = labeling.settings() print(palyr....
3
votes
0answers
55 views

Using input layer as output in PyQGIS for QGIS Modeler?

I have written a simple Processing script to rename a given field. It works successfully, changing the input layer's field name. However, I have not been able to produce an Output. This is a problem ...
1
vote
0answers
27 views

Layer adding/removing using PyQGIS? [closed]

I'm working on a plugin which fetch data from Vector Layers and I'm trying to update the informations whenever a fitting layer is added or removed. At first, I tried with QgsProject.layersAdded and ...
1
vote
0answers
49 views

PyQGIS (3.6.3 Noosa) Why is self.iface.mapCanvas().setExtent() being overridden in plugin?

I am writing a plugin that first adds the Google Imagery XYZ tile layer and then adds various other layers - some from a GeoPackage and others by creating their geometry in PyQGIS. The last function ...
0
votes
0answers
28 views

Error message when trying to install first QGIS Plugin

I'm trying to study PyQGIS scripting and follow a tutorial. Following this tutorial I'm developing a plugin that returns "Hello World". I followed every step and copied all of the source code but get ...
1
vote
0answers
37 views

Using PyQGIS in standalone scripts and in PyCharm - ImportError: DLL load failed: The specified module could not be found. appears

I am trying to get PyQGIS (3.4.6) to work in a standalone script on Windows 10 - preferably in PyCharm, though not necessarily. A solution where I can externally call a python script with initialized ...
2
votes
0answers
48 views

Standalone error using Python 3: layer.isValid is False [duplicate]

I am trying to create a standalone application using Python 3.7 and QGIS3.6. on Windows 10. I have installed QGIS using the OSGEO4W method, in the 64-bit flavour. My issue is that when I try to load ...
0
votes
0answers
30 views

What signal can be used to get the selection change on a feature?

Right now I am using: self.iface.mapCanvas().selectionChanged.connect(FunctionThatReactsToTheSignal) But this one sends two signals, one for the deselection of the previous feature and one for te ...
1
vote
1answer
19 views

Append Symbol Layer PyQGIS3

I am updating a QGIS2 plugin to QGIS3. The following code in PyQGIS2 works: association_symbol = QgsSymbolLayerV2Registry.instance().symbolLayerMetadata("ArrowLine").createSymbolLayer({ ...
2
votes
1answer
39 views

Hide columns in QgsAttributeTableView with Python

I use this code to initialize QgsAttributeTableView and hide some columns in it in my custom widget: def __init__(self, layer, canvas, hidden_columns, cache_size=5000, parent=None): """...
1
vote
1answer
53 views

Apply color ramp to (QgsSingleSymbolRenderer) Simple marker

I'm using a QgsSingleSymbolRenderer to display various points and lines etc for a Line geometry. I have a Single symbol symbology to display the last vertex as a: Line > Marker line > Marker &...
1
vote
1answer
34 views

Expand or Collapse Layer Groups in PyQGIS3

PyQGIS2 has a function to expand/collapse a layers with a subset of styles in the Layers panel as follows: self.iface.legendInterface().setLayerExpanded(self.segments_layer, False) I know that in ...
2
votes
1answer
63 views

Making Upload button for shapefile in QGIS plugin?

I am new to Plugin Builder and creating my first plugin called NearestNeighbour. The below is GUI of my plugin made using Qt Creator I read in this link that it is important to rename Dialog Box, ...
1
vote
1answer
23 views

'NoneType' object has no attribute 'identify'

I'm trying to run a console script, but it gives an error: : AttributeError:'NoneType' object has no attribute 'identify' Yet it works well in QGIS 3.7 Here is the script: import sys import time ...
1
vote
1answer
26 views

Parsing an input parameter to gdal:rastercalculator formula in QGIS 3.6 Python script

For training purposes I'm writing a QGIS 3.6 Python script. The script takes as inputs a raster layer and band, and three float numbers (refmult, refadd, sunel) and computes a simple formula: ((layer@...
2
votes
1answer
57 views

Set label precision with QgsRendererRangeLabelFormat class

I'm trying to control the number of decimal places represented for a layer in my project. I can do this in the symbology tab like this: I want to do this in PyQGIS. Here is an example of how I would ...
1
vote
1answer
44 views

Area Value not getting reflected in attribute Table using PyQGIS?

I have a WardBoundary.shp file in my project. I need to find the area of each polygon ( representing different wards).With the help of this comment on Adding Area column in Polygon layer using PyQGIS?,...
-1
votes
1answer
82 views

Adding Area column in Polygon layer using PyQGIS? [closed]

I have a WardBoundary.shp file with Polygon Features in it. I have to calculate the area of each Polygon and write into attribute Table. I can do manually by using '$area` but I need to automate ...