Questions tagged [pyqgis]

Python bindings for QGIS.

998 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7
votes
0answers
400 views

Developing QGIS Python plugins using Jupyter?

Is it possible to run PYQGIS commands using Jupyter notebook and, if so, is there any documentation to develop QGIS plugins using Jupyter?
7
votes
0answers
198 views

QgsSpatialIndex partial or complete overlap

I'm working on adding some functonality to a QGIS plugin. It currently uses a QgsSpatialIndex to efficiently compute whether the features of a vector layer intersect (potentially millions) of ...
6
votes
1answer
683 views

Editing Layout-Items after loading a QPT-Template in QGIS 3 with Python

I am facing a problem with the new Layout API while implementing a plugin for QGIS 3. Starting point is a layout template in qpt-Format, which contains different elements like (attribute) tables, map, ...
6
votes
0answers
351 views

Adding layer using QgsMapLayerRegistry within thread PyQGIS Plugin

I am developing Python QGIS plugin, where I am opening two threads in run function with one thread performing calculation while second thread is printing value looping and when first thread is ...
6
votes
0answers
580 views

Gdal and module import error when creating an .exe application with pyinstaller

I’ve been struggling since three days in a row to create a windows executable application from my python application. I have managed to get results but I’m not at all satisfied with the workarounds I ...
6
votes
0answers
280 views

How to change the group icon in legend via Python in QGIS 2.6?

How to change the group icon in legend via Python in QGIS 2.6? At version 1.x I did it this way: self.legendTree = self.iface.mainWindow().findChild(QDockWidget,"Legend").findChild(QTreeWidget) ...
6
votes
0answers
814 views

How to load the layer style from Postgresql with Python?

I would like to write a python macro that upon opening my QGIS project file will reload the default style for each layer from the postgres 'layer_style' table. I have had a look at the documentation ...
5
votes
2answers
159 views

Automatically moving along columns within a layer as moved to the next item in a QGIS Atlas?

My problem is quite hard to explain, I have attached some images to help illustrate my issue. I want to produce a large number of maps which overlap in geographic area. Currently my data is arranged ...
5
votes
1answer
153 views

Multi-field labeling of shapefile with PyQGIS?

I wrote the following code in order to draw the line labels with multiple fields. However, the label do not appear automatically in QGIS and I have to switch the "Layer Properties/Labels", and toggle ...
5
votes
1answer
229 views

how to save as output layer from QGIS processing algorithm to postgis database using pyqgis

I have two layers(layer1,layer2) in postgis database where I have connect in QGIS project. my database have specific precision. now I want to use from QGIS processing some algorithms like ...
5
votes
1answer
419 views

Competing versions of GDAL

This is confusing, and a question I've harvested from a duplicate, so let me start with my setup. OS: Windows 7 x64 GIS Client 1: ArcGIS Desktop 10.5 GIS Client 2: ArcGIS Pro 1.4 GIS Client 3: ...
5
votes
0answers
190 views

PyQGIS composed Atlas generation

I have some layers : layer 1 layer 2 layer 3 and I have create styles for any labels layer using base rule styles and labels and I have create a template .qpt and I use atlas correct. In my ...
5
votes
0answers
281 views

QgsRasterFileWriter.writeRaster() is crashing python program

I am doing ndvi analysis on a farm image. After ndvi I need to convert the image into Singleband pseudocolor image using following python code. def calculate(): file_name = CUR_DIR + "\...
5
votes
0answers
504 views

Importing numpy array into QGIS?

I have some computation on a numpy array and want to display the result in QGIS. So far ok, but loading the result into QGIS fails. Here my code fragment: zData2 = np.subtract(myarray,zData2) #do ...
5
votes
0answers
315 views

QGIS modeler - use input filename in output filename

I need to use the input filename in the output filename in a QGIS model. I have spent a couple of hours trying to find a solution but can't. If the input is contourXY.tab and I want output to be \...
5
votes
0answers
1k views

Connect to QGIS 2.6 Python Plugin function via button on custom feature form

I am trying to connect to a QGIS 2.6 Python plugin function via a custom feature form button. On my feature form, I'm attempting to do a few things : enable the updateButton only if the ...
5
votes
0answers
879 views

Print Composer Template produces empty map?

I have a print composer template which I'm trying to populate with different subset queries from a CSV-derived vector layer using the Python API. However, all the output PDFs contain everything except ...
4
votes
1answer
95 views

Layout export from stand-alone PyQGIS script shows empty map

I have a problem with exporting of a QGIS layout by the pyQGIS. I have prepared the qgz project and also the qpt layout. When I try to export the layout to PDF by QgsLayoutExporter.exportToPdf by ...
4
votes
0answers
111 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
266 views

QGIS 3 Python plugin psycopg2 Postgres Notify/Listen Live Connection

I'm developing a plugin for QGIS3 for my company, where my managers can allocate tasks to other users. I have programmed two tables within the python script, witch will be only visible according to ...
4
votes
0answers
210 views

Splitting lines/creating vertex at intersection using PyQGIS?

I am looking for an easy way or function to split 2 previously selected line features (generate vertex) at intersecting points (or touching points). See the following picture: I am developing a ...
4
votes
0answers
110 views

Speed execution of PyQGIS algorithms

I don't understand why if I do "manually" some algorithms I get results much faster than when I insert the same in a pyqgis code (with the same input). This happens, for example, with the extract ...
4
votes
0answers
106 views

PyQGIS memory issues

I have some big problems with the memory usage of my standalone PyQgis script based on QGis 2.18 and run on ubuntu/linux (happens also on Windows 10 though). I will document it very precisely using ...
4
votes
0answers
78 views

Halftone effect gridded points inside polygon

I am trying to create smooth looking polygons by gridded points in QGIS (2.18.16), with a fading effect towards the boundary of the polygons (halftone effect). By using the 'fillGrid' function from ...
4
votes
0answers
250 views

QGIS (Python) crashing when trying to iterate through layers in a thread

Version: 2.18, and I cannot upgrade to 3. I am adapting a script I found elsewhere on stackexchange which is supposed to indefinitely refresh all layers in the TOC at one-second intervals. This is ...
4
votes
0answers
234 views

Installing third party python library in QGIS 2.18.x Windows

We are running into a strange behaviour while trying to use pyoidc with QGIS 2.18.x windows standalone version. Due to pip/pipy no longer working with QGIS 2.18 (see this post), we installed the ...
4
votes
0answers
204 views

Get signal on delete group on QGIS 2.18.16

I tried : QgsProject.instance().layerTreeRoot().willRemoveChildren.connect(self.onWillRemoveChildren) It works if I delete a group within in the root node. But if I delete a layer within a group ...
4
votes
0answers
174 views

Minidump in C when executing Python script

I have written a python script which should calculate the azimuth for a line (with two given points). But every time I run the script, I am getting the following error message: If I click OK, QGIS ...
4
votes
1answer
160 views

PyQGIS spatial operators(contains,equals,etc.) w.r.t. layer geometries(polygon,point,line,etc.)

I am trying to implement QGIS spatial query functionality in my plugin. I want to eliminate spatial operators which are not suitable for certain geometries. For eg. when I select layer with point ...
4
votes
0answers
111 views

Relation/difference between area calculated by PyQGIS QgsDistanceArea().measurePolygon() and QGIS $area

What is relation/difference between area calculated by QgsDistanceArea().measurePolygon() of PyQGIS and $area from geometry $area in QGIS? I am getting area as 0 for one polygon using QgsDistanceArea(...
4
votes
0answers
347 views

How to run v.clean tool for break in QGIS Python Console

How to use v.clean GRASS processing tool in QGIS from Python QGIS Console. I have tried using below command: processing.runandload('grass:v.clean', layer, 0,0.100000,'8132391.27018,8134827.49723,...
4
votes
0answers
215 views

Geocoding an address involving non-ASCII characters in PyQGIS

I have installed the "GeoCoding" plugin in QGIS and it worked well even though I have used non-ASCII characters to geocode (i.e. Hacettepe Üniversitesi). However, when I tried to do the same in PyQGIS ...
4
votes
0answers
29 views

QGIS script accessing old version of layer

I have added a couple of fields to a postgis table which is loaded into a layer in QGIS. When I access the attribute table in QGIS I can see the two new fields but when I run a script (using ...
4
votes
0answers
542 views

Import Pandas or any Python module into QGIS internal Python

(Also asked in stack overflow - https://stackoverflow.com/questions/43244062/import-pandas-or-any-python-module-into-qgis-internal-python ) I am developing a plugin for the current LTR version of ...
4
votes
0answers
582 views

Right-hand-rule in QGIS

It seems that there isn't a plugin to perform the right-hand-rule on a layer or selected features. Can this be done by using some Python code? Is there a function that works in the same way as ...
4
votes
0answers
268 views

Reopening QGIS project from PyQGIS

I am opening a QGIS project using the following snippet: new_project = False if not os.path.exists(self.qgis_project_path): prj_template_path = os.path.join(self.qgis_template_path, 'project.qgs')...
4
votes
0answers
97 views

Seeking list of project properties that can be written in PyQGIS?

The methods QgsProject.instance().writeEntry() and QgsProject.instance().readEntry() can be used to programmatically set project properties. According to the QGIS API reference the properties ...
4
votes
0answers
231 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
4
votes
0answers
74 views

Loop distance point PyQGIS

I have a .shp of lines where I'm able to calculate the sum of segments length but I'm trying to put a point at a given distance in meters. The problem is it puts a point at every segment. When I give ...
4
votes
0answers
92 views

Issues updating field values programmatically for particular field data type on 64bit Windows computer using QGIS 2.8.7

I have an issue with a plugin for QGIS 2.8 I'm developing when using it on a Windows 64bit machine (as opposed to 32bit). I am trying to update values in a particular field in my plugin, and the ...
4
votes
0answers
105 views

Open QGIS project files in exclusive mode / alert if project file already in use

I have QGIS-Project-Files saved to a network drive and was wondering if it is possible to warn users that a project file is already opened by an other user to prevent concurrent editing of the same ...
4
votes
0answers
357 views

PyQGIS: vector layer does not get displayed after rendering

My project goal is to write a standalone app for Unbuntu and QGIS 2.14. It should get a layer of simple points and their name from a Postgres database and show them in a layer. In addition there ...
4
votes
0answers
74 views

Parallel feature request connection limit

I have a large pool of feature requests that need to be performed on a PostgreSQL layer. Please assume that these requests cannot be joined into larger requests. If I spawn several threads to perform ...
4
votes
0answers
698 views

module object has no attribute classFactory

I asked this question several days ago on the QGIS developer list but didn't get any love. I'm hoping someone can help me resolve this error. I have a custom repo and a custom plugin that I'm ...
4
votes
1answer
275 views

Showing only selected features from a a layer in the QgsComposerLegend?

I have developed a custom qgis plugin. I have a button to export the map canvas in the form of image along with the legend. I came up with the following code for the legend: legend = ...
4
votes
0answers
183 views

Can you build a login window in QGIS?

Can you build a login window before loading QGIS interface? I use QGIS 2.8 I just built message windows when loading QGIS interface, but no more.
4
votes
0answers
72 views

QGIS plugin window qt creator formatting is ineffective

I am developing a QGIS plugin. I have assigned the QGIS main window as the parent window of custom plugin using: QtGui.QDialog.__init__(self, iface.mainWindow()) But after doing so the problem is ...
4
votes
0answers
236 views

How are costs returned by the pyQGIS implementation of Dijkstra calculated?

How are the costs returned by pyQGIS implementation of Dijkstra (QgsGraphAnalyzer.dijkstra) calculated? As far as I know, these costs correspond to the distance from the starting node to each of the ...
4
votes
0answers
4k views

How to import netcdf in qgis

I have been trying to impot netcdf files following this guide online http://www.ggiuliani.ch/download/netcdf_qgis_GG.pdf into qgis 2.10 with no success. ALthough the file is imported, the dimensions ...
4
votes
0answers
290 views

Is it possible to lock the layers using Qgis API Python?

I would need to load and "lock" two layers on the map. Locked means that layers cannot be removed from the layer registry. When I say removed I mean removed by the user using the QGIS interface (the ...