Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
0answers
54 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 ...
1
vote
0answers
15 views

QgsPalLayerSettings is not defined

So I'm writing some script for QGIS 1.8 and I'm unable to resolve this error. from qgis.core import * pallyr = QgsPalLayerSettings() The second line gives me error that QgsPalLayerSettings is not ...
1
vote
0answers
41 views

Can QGIS handle EMPTY geometries?

I am writing a plugin and have a postgis table which has EMPTY geometries in the geom column. MULTILINESTRING EMPTY I am having crashes which just close QGIS. I have narrowed it down to the EMPTY ...
1
vote
1answer
32 views

Get distance from point to nearest edge of polygon with PyQGIS

I have 2 .shp layers in my workspace, polyLayer and pointLayer Using PyQGIS I'd like to be able to get the distance from the point to the nearest boundary of the polygon. I've done this sort of ...
0
votes
1answer
19 views

Add event listener on QGraphicsEllipseItem

I'm creating a QGis Plugin in python which has a QGraphicsView in which I draw and ellipse on which I want to detect if the user clicks. I know the ellipse inherits QGraphicsItem which has a ...
2
votes
1answer
58 views

pyQGIS changing Paletted Raster Layers to Grayscale

I've written a plugin which essentially imports a number of colour geoTifs (map tiles) which works correctly but it would be great to display these as Grayscale after loading in. The geoTifs load as ...
1
vote
2answers
48 views

How to prompt for layer selection from python console in QGIS?

During script development it's useful to use the QGIS python console to test the same script on different layers. Currently I've been hardcoding layer strings and just swapping out but it isn't ...
1
vote
0answers
23 views

Enable editing only one feature in a Polygon Layer using PyQGIS

I was thinking of locking neighboring polygons (parcels) by disabling editing on them, while editing would be possible on the polygon at the center. This means other polygons can also be edited in ...
0
votes
0answers
11 views

Error using gdal IDW in processing script for postgis layer

I am running QGIS 2.10.1 and I am trying to use the processing toolbox to interpolate a point layer. If I use a shape file with all the default settings it works well but if I use a point layer coming ...
0
votes
0answers
19 views

How to set QGIS mapCanvas to exact values

My QGIS 2.8.2 standalone app's mapCanvas fills a central widget with a fixed quadratic size x=y=1000 pixels. When I set the mapCanvas extent() to an area defined quadratic as well given by a ...
1
vote
0answers
15 views

add different custom SVG markers to categorized section using pyqgis

I am trying to find a way to add different custom SVG markers to the categorized symboling. I would like to have different symbols for different values but unfortunately I cannot find a way to do it ...
0
votes
0answers
17 views

Custom QGIS Processing Tool Fails to Copy Features

I'm creating a custom QGIS Processing plugin. I've created a tool that is basically supposed to copy features from an input PostGIS layer to a new PostGIS layer. My routine runs without errors and ...
1
vote
0answers
34 views

Running a custom function on each line of a PostGIS table

I am trying to run a custom function on each parcel in a PostGIS table, (in this case its a function that finds the standard deviation value of the pixels intersecting a raster) Here is the code for ...
1
vote
1answer
80 views

Sorting points based on Northing and Easting

I have around 1320 point/centroid features in a shapefile for my research plots. Each point/centroid has X and Y coordinate associated with them which were calculated using Field Calculator > Geometry ...
1
vote
1answer
59 views

Can't get my QGIS external map to display on Ubuntu trusty: QObject::connect: Cannot connect (null) error

I've been following along the examples from the book "Building Mapping Applications with QGIS and for the life of me I can't figure out why my shape files aren't loading and displaying in the app ...
1
vote
1answer
50 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 ...
2
votes
1answer
54 views

How to launch Processing tool User Interface using PyQGIS?

I am trying to launch the UI 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 is a water ...
1
vote
0answers
32 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
39 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
59 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
111 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
2answers
62 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
1answer
53 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
27 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
34 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
60 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
26 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
16 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
46 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
11 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
36 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
19 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
60 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
62 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
27 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
34 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
21 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
39 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
54 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
67 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
2answers
62 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
53 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
66 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
34 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
28 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
50 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
30 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
48 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
58 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
44 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 ...