Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
1answer
12 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 ...
1
vote
0answers
7 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 ...
1
vote
0answers
29 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 ...
0
votes
0answers
6 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
1answer
22 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 ...
5
votes
2answers
739 views

Load and display a layer from SQL Server using PyQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
1
vote
0answers
12 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
9 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
16 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
9 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
12 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
1answer
77 views

Identifying Left and Right Mouse Button Clicks in PyQgis application

I am relatively new to PyQt. I am trying create a custom plugin for Qgis which enables the user to select some features by drawing polygon on the canvas using mouse clicks and then performs ...
1
vote
1answer
71 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
37 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 ...
2
votes
1answer
49 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 ...
3
votes
2answers
54 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 ...
3
votes
0answers
53 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
1answer
46 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 ...
1
vote
0answers
13 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
1answer
71 views

How to get the signal when the color changes in pyQGIS?

I would like to have the signal when the color of a vector layer is changed by the user. In the doc, there is a signal that seems to fit ...
1
vote
2answers
50 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, ...
1
vote
1answer
597 views

How to delete selected features in Qgis using Python

I have a shape file with only one field DN. I would like to delete all features which does not have specific value of the field. Let say the DN can be 1,2 or 3. So far I was able to find out how to ...
1
vote
0answers
18 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 ...
1
vote
2answers
229 views

How to create a polygon feature using Python?

I'm making a plugin for Quantum GIS in python. I have a polygon layer and want to create a new feature. So far, I have this because I need a polygon geometry to add the feature: surface = ...
2
votes
1answer
36 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
1answer
931 views

QGIS python - reference a layer in the table of contents

I'm trying to create a plugin for QGIS using python, But need some help. I want to 1.Zoom to a layer and 2. make the layer visible(switch off or on). But I have managed to zoom to an active layer by ...
2
votes
1answer
355 views

How to begin with tool development for GRASS gis or QGIS GRASS

I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...
1
vote
2answers
24 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
2answers
3k views

How to access attribute data type in QGIS?

I've been developing a plugin on QGIS platform using PyQGIS. So far plugin does the following: You can select any feature of the already loaded vector layer in QGIS. After selection, plugin displays ...
2
votes
1answer
27 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
41 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
16 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 ...
1
vote
2answers
50 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 ...
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

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 ...
1
vote
2answers
54 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. ...
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 ...
11
votes
1answer
267 views

How to copy the color styling to a color column in a layer's attribute table?

I have a polygon layer in QGIS that I have applied a random color style to each polygon. Under Layer Properties -> Style I selected a Categorized style and then generated a random color ramp. I added ...
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 ...
3
votes
1answer
41 views

Refreshing “layer render order” widget

i made changes in the render order of my map canvas using a : qgis.utils.iface.mapCanvas().setLayerSet(a) "a" being a list of QgsMapCanvasLayer My code is working as expected (i see result on map ...
2
votes
1answer
149 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
1
vote
1answer
51 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
23 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 ...
2
votes
2answers
33 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
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, ...
1
vote
1answer
39 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
2answers
315 views

How to determine the coordinates of the corners of the raster layer

How can we determine the coordinates of the corners of the raster layer? The image opens function QgsRasterLayer.
2
votes
1answer
62 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', ...