Python bindings for QGIS.

learn more… | top users | synonyms (1)

10
votes
0answers
220 views

PyQGIS save raster as rendered image, then use GDAL tools on it

I have tried to use the code from QGis Save Raster as Rendered Image. i is a raster layer: pipelayer = i pipeextent = pipelayer.extent() pipewidth, pipeheight = (pipelayer.width(), ...
8
votes
0answers
131 views

How to access a deleted features attributes (before committing)

I have a signal setup for a feature deletion event on a layer: self.layer.featureDeleted.connect(self.feature_deleted) When I try and grab an attribute from the deleted feature on the slot, a ...
7
votes
0answers
73 views

QGIS: large .vrt indexing

I have a large number of small tiles merged into a single VRT. The rasters are only viewed at large scale, so only a few of them are visible at the same time. The map refresh in qgis is slowing down ...
6
votes
0answers
91 views

Can a memory layer be used as an input and/or output with runalg?

Can a memory layer be used as an input and/or output with runalg? With runandload I get this to work: processing.runandload("qgis:mergevectorlayers","memory:bufferOne", "memory:bufferTwo", ...
6
votes
0answers
314 views

Performing buffering and intersection with script in PyQGIS

I wrote a script that performs the intersection of two layers: The first Layer -> layer1, represents the rivers The second Layer -> layer2, represents a set of circular dots distributed in a ...
5
votes
0answers
51 views

See python script running while processing a task in QGIS?

Is it possible to see scripts running in Python Console - everything from tools and analysis vector to raster?
4
votes
0answers
48 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
24 views

Qgis Python - Legends in Horizontal

I have successfully added legends in Map using Qgis QgsComposerLegend () python programming .(using Qgis python console) but legends are added vertically.I wanted to place legend horizontally. If you ...
4
votes
0answers
26 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
39 views

How do I implement PyQGIS multithreading to update a progress bar

I am developing a PyQGIS plugin using python. I facing a problem during the implementation of threading in my plugin. I have written a python script which contains a class wrapping all geo-processing ...
4
votes
0answers
75 views

How to load layers from postgres using SELECT statement?

I am trying to load a postgres table (columns extracted using a select statement) from the python console in QGis: The following works fine and the layer loads as expected: uri = QgsDataSourceURI() ...
3
votes
0answers
17 views

The features don't appear at the first time in my exported PDF

my problem consists of exporting to PDF format. The first time I run my code (Text Editor of QGIS) the PDF only has the legend. But the second time, it has the features. Changing the line of ...
3
votes
0answers
49 views

Setting default label font in QGIS?

QGIS currently does not have a way to set a default font to be used for labelling, and being lazy I'm getting tired of having to set our house font styling for every layer I create or use (see change ...
3
votes
0answers
40 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 ...
3
votes
0answers
65 views

How to create a shapefile having Voronoi diagrams from the shapefile of an existing region?

I have a shape file of a region and I want to generate random sub regions of that shape file using Voronoi class of scipy.spatial package of python. But I am a newbie to GIS. I found out about Voronoi ...
3
votes
0answers
44 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 ...
3
votes
0answers
67 views

Python script to automate saving satellite images for different combinations of lat longs

PS. : This is my first try at a GIS application. Please forgive if my question is pedantic. I would like to get a series of satellite images all at the same scale centered around different points on ...
3
votes
0answers
94 views

Can qgis_core work with external python distribution (such as Anaconda)

I've built a python application that has its own GUI. I am trying to use qgis.core/pyQgis as map display only. Specifically, i have anaconda 2.3 and its python distribution (2.7.11). After research on ...
3
votes
0answers
60 views

How to show 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 = ...
3
votes
0answers
78 views

spatial index intersection with qgsrectangle only computes polygones

I have the problem, that i only get polygon features inside my defined rectangle. If i switch off my polygon layer(s) i get my lines. TOC: Line-Layer on, Polygon-Layer on: i only get Polygons which ...
3
votes
0answers
58 views

PyQgis: Print Composer using input from several Spatialite-tables

How can I create PDFs out of QGIS using the Print Composer Templates that include a lot of text (from a text-template) and within the text several information comes out of my spatiallite-database. A ...
3
votes
0answers
66 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 ...
3
votes
0answers
175 views

QGIS 2.8 Python Plugin Unittest Segmentation Fault 11

UPDATE: This issue may be isolated to my MacBook. The seg fault did not occur in testing on Windows. I have put together a sample unit test for a QGIS python plugin. It is causing a Segmentation ...
3
votes
0answers
488 views

How to stop a PyQGIS script that has an infinite loop, using the keyboard?

So i wrote a script that does what i want over and over again using a "while True:" in a certain time interval (every 5 seconds using time.sleep(5)). So far so good BUT when i want to stop it i just ...
3
votes
0answers
155 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) ...
3
votes
0answers
73 views

PyQGIS: standard and advanced linear referencing possibilities

I'm aware of the existence of the following QGIS plugins: QChainage Event layer linear referencing LRS Although, all of these tools offer some linear referencing capabilities, I find that they ...
3
votes
0answers
360 views

Retrieve a point coordinates from map canvas using QGIS API

I'm trying to build a plugin that firstly captures the map coordinates. I have tried to adapt the map tool explained in this post: How to programatically check for a mouse click in QGIS The code I ...
3
votes
0answers
94 views

access point layer representation in qgis with pyqgis

I am exporting the style of a categorized point layer with qgis: unfortunately my code only extract the size of the symbol in the definition of the properties of the layer but not the ...
3
votes
0answers
160 views

PyQGIS: How to color raster layer with existing colorBrewerMap

With pyqgis I have added multiple new raster layers to the legendinterface(). Because i like the ColorBrewer style i want to color some of them with the "Spectral" gradient. How can I do this in ...
3
votes
0answers
173 views

Programmatically selecting features by polygon

Expanding upon this post how could you use QGis to programmatically draw a selection polygon and select features within the polygon? I have been using QgsMapToolEmitPoint(self.canvas), to find and ...
3
votes
0answers
161 views

How can I change the NoData value in QGIS 2.x using the python console

I'm trying to add a NoData value to a single band raster image in QGIS 2.0 using the python console but can't find the right bit of code to do it. Here's what I see on the console: >>> ...
3
votes
0answers
473 views

How to load the default 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 ...
3
votes
0answers
974 views

How to change feature's geometry?

Hy, I'm creating my layer like this: crs = core.QgsCoordinateReferenceSystem(4326, core.QgsCoordinateReferenceSystem.EpsgCrsId) uri = "Polygon" uri += '?crs=' + crs.authid() uri += ...
3
votes
0answers
218 views

Setting border-style to 'no pen' using QgsGraduatedSymbolRendererV2

I am developing a QGIS plugin that, after a series of inputs, will produce a thematic map using the QgsGraduatedSymbolRendererV2. Because the polygon are very small, the boarders make it such that ...
2
votes
0answers
17 views

Approach to controlling which layers display in a QgsComposerLegend

I've tried 2 approaches to control what shows up in print legends. Neither of them work which is troubling because other than pruning the layerRootTree in advance of composer.addItem(legend), there ...
2
votes
0answers
15 views

Create different print composers from different layers added to QGIS

I'm using QGIS 2.8.3 with windows 10. I want to know if it's possible and how to create, using python code, from each layer (in the table of content) a print composer to each one of them. Any ...
2
votes
0answers
47 views

Problem using processing.runandload()

I'm writing a QGIS plugin using PyQGIS and I have a weird problem. When executing following line of code: processing.runandload("qgis:createpointsalonglines", r"Clipped", 1, 1, 0, r"memory:nodes") ...
2
votes
0answers
46 views

Deployment of optical fiber QGIS Python

The subject that I’m working on is the deployment of optical fiber . I have a shapefile which represents a country containing homes. And I have another shapefile representing an infrastructure plan of ...
2
votes
0answers
24 views

How to programatically populate a field_4 after choosing values from other fields

I'm working with QGis 2.8, editing the attribute table of a SHP file, named "myTable". I need to populate field_4 with the conditions listed below: For 1 to n (it runs across records of myTable) ...
2
votes
0answers
58 views

How to add plugin icon to status bar using PyQGIS?

I would like add my plugin icon to the status bar at the bottom of the screen. How would I do that? (QGIS API documentation on statusBar() seems to be leading to the QT docs and that site is down ...
2
votes
0answers
41 views

Fatal Error when PyQGIS searches for available providers: QgsApplication.initQgis()

I am setting the prefix path in Python using the code below. When running the code, a pop-up window stating "python.exe has stopped working" shows up. I've gone line by line in the code within ...
2
votes
0answers
48 views

PyQGIS Error using standalone script when loading a vector layer

I've been able to execute the command below in the Python console in QGIS. I am able to execute from qgis.core import * and import qgis.utils with no errors in the OSGeo4W shell but adding the layer I ...
2
votes
0answers
18 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 ...
2
votes
0answers
15 views

PyQgis - How to update a spatial index?

I am trying to speed up a QGIS plugin I wrote by adding a spatial index to a vector layer. The aim of my plugin is to simplify a line network by merging some of its features, based on some criteria. ...
2
votes
0answers
62 views

Create a layer, edit and save. Where are my features?

I created a layer (e.g. point) in QGIS with QgsVectorLayer from memory: mem_layer = QgsVectorLayer("point?crs=epsg:32630&field=id:string","TempFile","memory") ...
2
votes
0answers
43 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 ...
2
votes
0answers
66 views

Loading a qgsproject when another one is loaded

I am loading a project with: QgsProject.instance().read(QFileInfo(path)) When i try to load another project it subtracts the layers and shows nothing. But if I try doing it again it works.
2
votes
0answers
75 views

heat map plugin from QGIS python console

I am trying to use the heat map plugin from the processing console. On the QGIS documentation it says the plugin uses Kernel Density Estimation. I have used the saga Kernel Density Estimation but do ...
2
votes
0answers
27 views

QGIS plugin window qt creator formatting ineffictive

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 ...
2
votes
0answers
169 views

Combining custom QWidgets with ui file generated from QGIS plugin builder?

I am having a hard time figuring out how I can include several QWidgets (created in individual scripts) into the QT Designer ui file generated from a QGIS plugin builder. These are custom widgets I ...