Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
11 views

Checking for Changes in a WFS

I'm responsible for updating many spatial datasets within my organisation. Some data suppliers notify me of a change, some suppliers don't. Sometimes it's not easily apparent if the data has changed ...
1
vote
2answers
19 views

How to join the attributes table from one input layer to another layer with unique id using python

I have one input layer with the attibute values and i wanted to join the attribute table of the input layer to the another layer with unique values using python. ...
1
vote
1answer
45 views

QStringList() error in plugin of QGIS 2.10

I have made a Dialog in PyQt for use it like a plugin under QGIS 2.10 The Dialog works fine like a standalone application, but if I try to call it like a QGIS plugin, I get this error: ...
1
vote
1answer
18 views

Failed to create memory layers in QGIS application on Linux

I have written a python class which reads properties of map layers from an XML file and creates appropriate memory layers. I have developed and tested this code with QGIS 2.8.2 on a Windows 7 machine ...
2
votes
1answer
25 views

How to dynamically change images in map reports?

I need to make a report about several cadastral parcels which data are contained inside three different tables of a database. Report must contain: Cadastral data taken from the three tables A ...
1
vote
0answers
18 views

How to write a test suite for QGIS standalone application

I have a rather simple QGIS standalone Python app (2.8.2, Windows 7/64), with some published methods to create different types of geometric primitives (rectangles, circles). class MyApp(QMainWindow, ...
2
votes
2answers
30 views

Where is the QGIS API action for “deselect”?

Where is the QGIS action for the “deselect” toolbutton in the 'Attributes" toolbar? I do not see this action in the QgisInterface class or do not recognize it by name. Is it missing from iface? I'd ...
1
vote
1answer
31 views

How to calculate zonal statistics from multi-band raster for each polygon using python?

I want to calculate the zonal statastics from multi band raster for a polygon layer. When I am using this snippet of code: vectorlayer=qgis.utils.iface.mapCanvas().layer(0) rasterfile = ...
2
votes
1answer
61 views

How to avoid a QGIS crash when it is appended a symbol layer in a symbol?

When I run the next code at the Python Console of QGIS with a line vector layer: symbol1 = QgsLineSymbolV2.createSimple({'penstyle':'solid', 'color':'black', ...
2
votes
0answers
17 views

PyQGIS Use of predefined color ramps

I´m trying to apply one of predefined color ramps to a categorized field in a vector layer. To do this, I'm using the code below suggested by Irssvt in another post. However, I cant´t see the result ...
1
vote
1answer
37 views

How to create a polygon grid with un-even spacing between research plots?

I have an orthomosaic of a crop field with small research plots (3.8 X 1.44 m and 0.22m b/w plots and 0.50m b/w range spacing). I would like to create a polygon layer using this information. After ...
1
vote
0answers
56 views

How to wait for mapCanvas render before taking a screenshot?

i am trying to iterate over a large list of features and making a screenshot of the selected feature. My problem is that it seems to be a delay between the refreshing of the canvas and the taking of ...
1
vote
1answer
24 views

Styles not applied when using QgsMapRenderer

Using pyqgis, i am trying to export some maps as images using QgsMapRenderer. Here is the layer/style setup, both load correctly: lyr = QgsVectorLayer(uri.uri(), 'Report', 'postgres') styleload = ...
1
vote
0answers
23 views

How to react to network events

I am in the process of writing a Plugin which should react to some data (XML-Format) sent via a socket connection. Since I have never worked with IPC in terms of python before and my knowledge of IPC ...
1
vote
1answer
39 views

How to get the coordinates inside the polygon using python

I have a polygon and using this code snippet we can get the coordinates boundary of the polygon. canvas = qgis.utils.iface.mapCanvas() aLayer = canvas.currentLayer() coord = ...
2
votes
1answer
24 views

Show VectorLayer in window

I'm new in PyQgis. I can create vector layer and lines/polygons on it : layer = QgsVectorLayer("LineString", "points", "memory") pr = layer.dataProvider() pt = QgsFeature() point1 = QgsPoint(0,0) ...
3
votes
1answer
39 views

Moving cursor using PyQGIS?

I would like to move the cursor to a given x,y coordinates of the MapCanvas. Is there an easy way to do this using PyQGIS?
2
votes
1answer
52 views

Processing algorithm fails from Python script

I'm trying to write a Python script performing a geoalgorithm. What is surprising me is the following: I first test the algorithm by QGIS (2.8) interface. In my case, the GRASS interpolator ...
2
votes
1answer
37 views

The QGIS atlas defined with pyqgis and a QPT template exports the same maps

I need to generate an atlas for each feature from a layer for reporting. There will be created a few maps. The centre of each map must be focused on each feature. In this task I use a predefined QPT ...
2
votes
1answer
36 views

QGIS crashing/failing when dissolving multiple shapefiles in a Python loop

I am using QGIS 2.10 (but I've also tried 2.8) to loop through all the shapefiles in a folder (those ending in .shp) and perform a dissolve function on each of them. However, when I run the following ...
1
vote
0answers
39 views

How to define a custom function that returns value of a field in an unsaved form

Filter expression builder in QGIS 2.8 allows us to define custom functions using python. I'm intrested would it be possible to define a function which returns a value of a field in an unsaved form ...
1
vote
1answer
26 views

Python ogr filter attribute SQL

I have a shapefile with 4 attribute fields (MC_ID, MC_info, C_ID, C_info). I want to change some MC_ID values selecting the features by C_info. For example: I want to set MC_ID = 2 for C_info = g19, ...
1
vote
1answer
28 views

Valid shapely dumps WKT becomes None when used as input to QgsGeometry

I'm trying to produce a multipolygon feature in QGIS. I am producing filled contours with Matplotlib, taking the multipolygons representing each contour level, using shapely to produce WKT, and then ...
2
votes
0answers
38 views

How to change the symbology of selected features in QGIS

In QGIS selected features are normally highlighted in a different color to draw user’s attention on the selection. The default color can be changed programmatically. As a nice to have my standalone ...
0
votes
1answer
64 views

Accessing layer's visibility presets?

is there a way to programmatically access the layer's visibility presets defined in the layer tree view widget ? (methods, properties ... ?) Thanks ! To avoid misunderstandings the part i want to ...
1
vote
2answers
29 views

Importing fmeobjects into PyQGIS

I use FME a lot for manipulation of spatial data, and would like to leverage it's Python library, fmeobjects in PyQgis. If I run the following in my standard Python IDE it works fine: import sys ...
2
votes
1answer
63 views

QGIS Plugins & Tools that replicate Select ArcPy Tools

I developed a complex python application for road generation from GPS Devices that uses a few Arcpy Tools. I want to try and replicate this Applications functionality using a freeware like PyQGIS ...
1
vote
2answers
55 views

QgisInterface.addVectorLayer Error

I am Esri-trained, trying to move into QGIS using Python. Simply trying to add a vector layer in Qgis returns the below error: TypeError: QgisInterface.addVectorLayer(QString, QString, QString): ...
2
votes
1answer
56 views

different way to build qgis python standalone application

There seems to be 2 different ways to start a Python QGIS standalone script. The official tutorial is using : from qgis.core import * # supply path to where is your qgis installed ...
0
votes
1answer
44 views

How can we export shapfile to svg format using Pyqgis

I am doing a project where i have to export file from shapefile to svg format using Pyqgis. i have read some articles regarding simplesvg plugin but i don't know how can we achieve the same task using ...
1
vote
1answer
34 views

How to restrict panning in QGIS to a given extent

I'm going to build a QGIS standalone application. According to the requirements full extent equals to the extent of a predefined rectangle (say bounding box of a parcel). The application should start ...
1
vote
1answer
56 views

Finding and deleting duplicate records in attribute table in QGIS

I have around 1 Lakh+ (100,000+) point features in my shapefile, which has some duplicate records in it. I had found the duplicate records present in the attribute table and print those in python ...
4
votes
1answer
73 views

QGIS Export Shapefile

i am trying to export selected feature using pyqgis. till now i have tried these codes. after using this i can select feature but dont know how to export selected feature to new shapefile. canvas= ...
2
votes
1answer
47 views

Why does the QgsFeatureIterator crash in my stand alone script?

I'm trying to write a standalone script in qgis 2.10 in ubuntu I have written a script which crashes when I run from bash but works fine from inside the qgis desktop environment. The script is: ...
2
votes
1answer
46 views

Adding QGIS feature, that shows coordinates and scale, into a custom application

I'm writing a standalone application using PyQGIS and I'd like to add the QGIS feature that shows coordinates and scale as the cursor hovers over the map. I need to know this mainly in case of ...
3
votes
0answers
50 views

How to develop QGIS Plugin to fully run Spatial Queries With PostGIS?

I'm developing a QGIS plugin that fully run spatial queries with PostGIS. Actually I developed all spatial queries wish need some adjustment. I'm looking for some ressources or documents to know how ...
1
vote
0answers
40 views

What is the correct way to run a python script in QGIS Open Project macro?

This code (answer from @gcarrillo about other question - Is there any way to freeze the layer names in the TOC?) runs fine on python console and inside a plugin. But now, I tried put it within the ...
0
votes
0answers
17 views

Adding elements to the layer tree view ?

is there a way to add custom elements (checkboxes, or more ...) or change some elements properties (colours ?) in the genuine layer tree view of QGIS using PyQgis ? How should i do that ? Thanks !
2
votes
0answers
34 views

QGIS QgsLayerTreeGroup signal “currentLayerChanged”?

In a pyqgis context, I use the "currentLayerChanged(QgsMapLayer *)" signal of the QgisInterface class to do something when the current layer is changed, but I need now to do the same when I select a ...
1
vote
1answer
49 views

Loading GeoServer WMS raster layer in QGIS Python console

I am using the following snippet to load a raster layer deployed under wms service using geoserver, in qgis python console. I am getting False output. Any idea? registry = ...
1
vote
0answers
25 views

PyQGIS Standalone Crashes python.exe when zooming out too far / Process finished with exit code -1073741819 (0xC0000005)

I have the following PyQGIS Standalone App which is working fine so far. One little problem is that if I zoom out to the MaxExtent(by scrolling the mousewheel) the app crashes python.exe so that the ...
2
votes
1answer
31 views

Error: Algorithm not found (QGIS)

I wrote the following code using QGIS'API. import os from qgis.core import * import qgis.utils prefix_path = os.environ['QGIS_PREFIX_PATH'] QgsApplication.setPrefixPath(prefix_path, True) ...
2
votes
1answer
36 views

How to add a message bar to custom canvas?

There is a simple code to add message bar to main window in QGIS: iface.messageBar().pushMessage("Hello","World") My question is how to add bar to my custom canvas canvas = QgsMapCanvas() in ...
2
votes
0answers
49 views

Remove multiple fields from multiple shapefiles using a python script [duplicate]

I'm using the python console of QGIS 2.8.1-Wien. I have a shapefile with many fields in the table that I want to remove them. I tried to use this geoalgoritm as: ...
1
vote
0answers
50 views

import qgis.core problem with QgsFeature and QgsGeometry ImportError: DLL load failed: The specified procedure could not be found

I've tried several previous answers to similar questions - no luck. I've tried everything, nothing seems to work. This is the error I'm getting Traceback (most recent call last): File ...
1
vote
0answers
28 views

PyQgis - Adding attributes to a POSTGIS layer

After reading @underdark's answer to this question on creating a new vector layer and @Matthias Kuhn's to this one on field calculation, I wrote a script that allows me to calcultate the mean ...
1
vote
1answer
34 views

How to get programmatically selected layers from the QGIS legend?

My QGIS plugin exports all layers from QGIS to KML format. Now I'd like to export only selected layers. However, I can't find any hints in QGIS API. Is it possible to iterate over selected layers in ...
2
votes
1answer
47 views

PyQGIS standalone script does not work. Error “QGraphicsScene::addItem: item has already been added to this scene”

I try to test a PyQGIS standalone script which should just show one Shapefile. Sounds pretty simple but does not work. Here is my script: from PyQt4 import * from PyQt4 import * from PyQt4.QtCore ...
1
vote
1answer
37 views

Adding the map canvas center to a composer label in QGIS

I am able to access the map canvas center in the python console in QGIS using qgis.utils.iface.mapCanvas().center() What I would like to do is get this into a map composer label. Is this ...
1
vote
1answer
50 views

Setting PYTHONPATH for compiled QGIS version on Linux

I'm trying to set the PYTHONPATH in order to be able to load the qgis classes in a python console (not the QGIS Python one). I followed some resources I've found (PYQGIS Cookbook, and others) but I ...