Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
14 views

My QGIS plugin shows GUI but not Works. How to get Error log?

I am new to PyQgis. I made a simple calculator with PyQt4, now I am trying to run it under QGIS. I connected calculator as plugin, and tested it, its GUI works without error but it does not calculates ...
0
votes
0answers
4 views

Launch processing tool user interface using python command

I am trying to launch the user interface of a processing algorithm using Python script but I cannot find a simple way for it (aside double clicking on it in the process toolbox of course). The plugin ...
1
vote
0answers
13 views

What solutions to use QGIS as insert tool for a Postgres relationnal database?

I have a Postgres/PostGIS relational database and I would like to use QGIS as an interface for inserting data. The thing is that my database is quite complex and I need my tool to handle the following ...
2
votes
1answer
34 views

How to find if map layer registry is empty?

In my script I want to open layer named my_layer if it is in the map layer registry. I use following code for it: inputLayer = QgsMapLayerRegistry.instance().mapLayersByName("my_layer")[0] If not ...
3
votes
0answers
36 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 ...
1
vote
2answers
48 views

Polygons in one layer have different attributes

Is it possible in PyQGIS to have in one layer more polygons and some would have one set of attributes and another different? E.g. Polygon_1(name, size, average_age), Polygon_2(name, size, ...
3
votes
1answer
26 views

How can I create a QGIS plugin that needs an external Python library?

I’m trying to enhance QGIS's Profiletool plugin by adding DXF export functionnality. For this, I need to to import dxfwrite library. As it's installed on my computer, i added the following lines to ...
2
votes
0answers
33 views

How to load a style from POSTGIS in PyQt

The thing is that I have four styles I have created in QGIS through the GUI and saved into a postgresql database. I can see them in the table named layer_styles I have seen similar questions asking ...
1
vote
2answers
22 views

How to put a frame around a legend using QgsComposerLegend?

I can already see this being a simple answer but I'm stumped with this. I want to create a frame around a legend created by a PyQGIS script Code snippet is: legend = QgsComposerLegend(c) ...
2
votes
1answer
25 views

QGIS: Finding electric network loops

With QGIS, how can we analyse an electrical network to find loops? Using Python is not a problem, however there is not a solution in the QGIS Python API. The QgsGraphAnalyzer has dijkstra and ...
2
votes
0answers
33 views

How to rename field names in a shapefile attribute table without table manager using python

By using the table manager we can rename the field names but i want to rename of fields using python. How can i do that?
1
vote
1answer
15 views

How to read non-spatial data using PyQgis?

I'm generating maps with QGis. What I do is generate a bunch of non-spatial data on a set of cities (using VBA), and still using VBA, generate a python code that will automaticaly output general map ...
0
votes
0answers
9 views

Iteratively Change Object's Instance Attributes PyQGIS

I am trying to create new instance attributes (NOT feature attributes) for a collection of features in a vector layer in PyQGIS. I'm getting some weird results and am wondering if this is even ...
2
votes
1answer
41 views

How to place labels at the boundary of the current map extent

I have a layer of reference grid lines on top of several map layers. The grid lines should be labeled with coordinate values: vertical grid lines with x-values and horizontal lines with y-values. The ...
0
votes
0answers
9 views

dynamic styles for rasters in qgis processing

I am writing a qgis processing script that loops a table column and does interpolation and would like to know if it is it possible to generate styles on the fly for raster layers and how to do it. I ...
1
vote
0answers
24 views

Using Multiprocessing inside a plugin in Qgis

I spent quite a bit of time looking on how to use the multiprocessing package, but couldn't find anything on how to use it inside a plugin in QGIS. I am developing a plugin that does some ...
2
votes
1answer
18 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
53 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
50 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
21 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
31 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
38 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
19 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
2answers
47 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
58 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
40 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
27 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
40 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
53 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
38 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
40 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
41 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
33 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
64 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
58 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
45 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
57 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
77 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
54 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: ...