Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
1answer
239 views

How to programmatically detect a canvas refresh or pan/zoom in QGIS

For my python plugin I would like to remove a VertexMarker when the user pans/zooms there map. Which is the best way to detect a canvas refresh or pan/zoom carried out by the user? Can you suggest ...
1
vote
0answers
212 views

How to change the color of a selected feature with pyQGIS?

is it possible to change the color of a selected feature in qgis 1.8? To highlight a feature I use: vlayer.setSelectedFeatures(selectedList) box = vlayer.boundingBoxOfSelected() ...
1
vote
0answers
90 views

How to join attributes by location with command line

I would like to joint the attributes of 2 shapefiles by location but with a command line (linux). This feature is easy in QGIS but it is VERY slow. Is there a way of doing this with ogr or pyqgis ? ...
1
vote
1answer
171 views

Why provider.nextFeature(feat) does not iterate over all layer features?

I have a point layer with over 1700 features, but iterating this way: i = 0 while provider.nextFeature(feat): i =i + 1 print '{0} de {1}: {2}'.format(i, ...
3
votes
3answers
1k views

QGIS 2 Python error on Mac OSX

Have just installed newly released QGIS 2.0. I installed the gdal package available at the official kyngchaos site. It seems to run ok, but when the program loads up I get a lengthy error message ...
3
votes
1answer
220 views

Looking for help for automatically making a QGIS map

Im looking at making a standalone script, that on execution will run the QGis MapComposer using a previously generated template and output a PDF/PNG of the map. This process of making a map will be ...
1
vote
1answer
173 views

QgsRasterLayer::identify() is missing after QGis upgrade to 2.0.1

My Ubuntu has just downloaded the latest version of QGis (1.8 -> 2.01), and my plugin failed with a plenty of bugs due to implemented changes in QGis API. I still can not figure out how do I replace ...
3
votes
2answers
417 views

Access Sextante (processing) in standalone QGIS app?

Sextante is addressable via python using the QGIS python console (unfortunately not from outside QGIS). I´m writing a standalone app and want to include Sextante geoprocessing functionality. In QGIS ...
0
votes
0answers
177 views

How can I embed IPython into the QGIS console?

I would like to use Ipython in the console to perform tasks more easily. How can I do that? Thanks a lot!
3
votes
1answer
2k views

PyQgis question: How to change or set active layer?

Developing a qgis plugin, I found that if no layer is selected in the Layers panel I can iterate over all layers and do anything to them, but "activate" them. Could someone give me a hint please? ...
4
votes
2answers
344 views

Best practice in writing automated tests for QGIS plugins

I'm looking for some best practice advice on writing automatic tests for QGIS plugins written in Python. I have written tests for Python scripts in the past using PyUnit (the unittest module), but ...
2
votes
2answers
461 views

How can I create a vector layer in PyQGIS from a table without geom column?

In QGIS I've got a Spatialite database containing tables without a geometry column. With the QGIS GUI it is perfectly possible to add such a table as a 'Spatialite vector layer'. But how to do this in ...
2
votes
1answer
839 views

How to import sextante(processing) for QGIS 1.9 (2.0)

In the current QGIS development snapshot the SEXTANTE toolbox has been merged into QGIS and is now known as "processing". This is a good step, but the previous import command doesn't work anymore. ...
2
votes
1answer
87 views

How to get access to layers without geometry?

I have a QGIS project with some layers without geometry. I develop a QGIS plugin. I want to get all my layers by: iface.mapCanvas().layers() but I get only layers with geometry. How I can get ...
3
votes
1answer
174 views

Get features in order they are selected using QGIS

Is there a way of establishing the order that a user selected features using QGIS and Python? By example: we have a network of line features representing a road network, and the user defines a route ...
1
vote
1answer
248 views

How to show QGIS plugin dialog always on top?

Is it possible to define for a pyqgis plugin, that the plugin dialog is always shown on top, after starting it from the toolbar?
5
votes
2answers
617 views

How can I define the layer CRS for a memory layer in pyqgis

how can I define the CRS for a memory layer from the qgis project settings vpoi = QgsVectorLayer("Point", "vectpoi", "memory") feature = QgsFeature() ...
0
votes
1answer
285 views

How to obtain rotation field name defined in the Labels “Data Defined” section in pyqgis?

I'm trying to find how to get with the QGIS Python API the layer field name that contain the rotation angle used by a layer to rotate its labels? I know that I can obtain the field name containing ...
2
votes
2answers
754 views

How to change the color of a vector layer in pyQGIS?

Is it possible to change the color while adding a vector layer? I have a vecot layer with water areas and want to load it with a blue color. The layer is added with: ...
0
votes
0answers
136 views

How to use the QgsMapToolIdentify in PyQgis?

I'm trying to implement the QgsMapTollIdentify class in a stand alone app but I can not. I am a newbie in Pyqgis and would like to ask how do I implement this class in Python? Thanks! Completing, ...
5
votes
2answers
1k views

How to use map composer in a stand-alone script?

I'm trying to follow the map rendering section from the pyqgis cookbook, but I'd like to test this as a standalone application. I can do the first part, using simple rendering, but I'm a bit stuck ...
0
votes
1answer
124 views

How to Resize the Qgis Main Window from python

I would like to write a plugin that simply resizes the qgis main window to make it small. How can I access the qgis main window through the qgis api? Use Case: We are having problems with qgis taking ...
1
vote
2answers
326 views

How to add a dynamic timeline to the QGIS canvas?

I am using the plugin Timemanager which works really great but there is one thing I'd like to improve. Instead of displaying the date and time on each frame, I would like to display a timeline ...
0
votes
0answers
67 views

How to change API version from 9.0 to 8.1 to load PyGIS

Traceback (most recent call last): File "", line 1, in RuntimeError: the sip module implements API v9.0 to v9.2 but the qgis.core module requires API v8.1
1
vote
0answers
218 views

Loading Vector Layer PyQGIS Issues

I am trying to follow PYQGIS documentation for loading a shapefile from inside a script. http://www.qgis.org/pyqgis-cookbook/intro.html I was able to set the datasource and run the QgsVectorLayer ...
2
votes
0answers
216 views

How to render a transparent raster layer on top of one or more vector layers with PyQgis?

I been trying to render a map with a 3 vector layers and one raster layer. The idea is that the raster layer should be on top of the other 3 vector layers. The problem is that even when I add the ...
1
vote
0answers
45 views

Can I use the PyQgis QgisPluginLayer to create heatmaps?

I am working in an application to generate maps from a bunch of MIF/MID files, I already created almost all the maps that I need, but, now I want to create heatmaps. I can't find any way of creating ...
3
votes
1answer
157 views

Can one expose variables to the Python console from a plugin in QGIS?

I have a QGIS plugin that performs a long-running operation, eventually producing and loading new shapefiles into QGIS. (I have this as a plugin rather than just a function that can be called from the ...
0
votes
1answer
339 views

AttributeError: 'QgsFields' object has no attribute 'itervalues'

First of all, the code which is below gives me the attribute names of a shapefile correctly if I use PyScripter IDE: from qgis.core import * from qgis.gui import * from PyQt4.QtCore import * from ...
3
votes
2answers
114 views

How to avoid the CRS Dialog when creating a vector layer memory?

I am trying to create a vector memory in a plugin. Basing on some examples,I was able to create a memory vector layer and to add it in QGis with : QgsMapLayer.instance().addMapLayer(myLayer,True) But ...
1
vote
2answers
377 views

How to use SEXTANTE in a script outside QGIS?

I´m trying to do some geoprocessing using the QGIS Sextante plugin outside of the QGIS application (and integrate it with different other libraries like arcpy, etc.). import sys, os from PyQt4.QtGui ...
1
vote
1answer
288 views

Problem loading PyQGIS

There is a problem on my system when starting QGIS. I get this error. I am running openSuse Tumbleweed 64bit and openSuse 12.3 64bit. Same problem on both systems. Couldn't load PyQGIS. Python ...
2
votes
1answer
229 views

Pyqgis vector layer rollback and commitChanges

I have problems with the vector layer rollback and commitChanges function, it doesn't matter wich one i call the vector layer is is Changed.Here is my code i hope someone can help me. This is my firt ...
1
vote
1answer
268 views

clip one layer with the current map layers

I work in a little companie where the main goal of employees in GIS is to have a quick view of the issues on a study area. It would be very useful to have a tool wich clip all the layers of the ...
2
votes
2answers
249 views

How to add non spatial sqlite table to map using python in qgis?

Is it possible to load pure sqlite 2.0 (without spatial extension) table into qgis using python? I would like to get the same result as in the case of using Add Vector Layer -> All files. I have ...
0
votes
0answers
424 views

Problem compiling UI file generated by QGIS Plugin Buidler

I have used the plugin builder QGIS 1.8 to create an empty plugin. The next step is to compile the ui file using pyuic. pyuic.py runs but halts at the line with from PYQt4 import QTCore and an error ...
2
votes
2answers
368 views

How to create a circle vector layer with 12 sectors with Python/pyqgis?

From a given coordinate and radius I need to create a circle with 12 sectors. The sectors should start from north (0 degrees) in 30 degree steps clockwise. I could also imagine to create the sectors ...
2
votes
1answer
94 views

How to set default bad layers handler in the python plugin?

I am trying to write a python plugin for QGis. My python plugin will copy a template qgis project into data catalog with ESRI shapefiles. Because data catalogs can vary in its content there will be ...
7
votes
3answers
617 views

What are QGIS Arcpy Equivalent Functions for Update/Delete Row/Field?

I am trying to reprogram some scripts from arcpy to qgis (1.8 or 2.0) and there are some simple functions that I want to be able to redo but unfortunately documentation in qgis is lacking in certain ...
2
votes
1answer
166 views

QGIS custom form: 'dynamic' default value

I am trying to make a custom form in QGIS to smoothen the digitizing process. For this purpose, I put the Edit widget (Layer properties, fields) of one of the fields on 'value map', and I loaded a ...
4
votes
2answers
1k views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
2
votes
0answers
255 views

PyQGIS joining a dbf to a shapefile

I am trying to join a shp and dbf file using the PyQGIS API. The code I'll use is below: from PyQt4.QtCore import * vector1 = QgsVectorLayer("path to dbf file", "test1", "ogr") id1 = vector1.id() ...
1
vote
1answer
274 views

Connect not working for custom QGIS form

So I have a custom form for editting feature attributes. However, I can't seem to correctly disconnect and reconnect certain bindings. The init code is below and should work for any simple QT widget ...
5
votes
1answer
593 views

How to programmatically associate a layer with a custom UI?

I know it is possible to associate a layer with a custom UI for editing feature attributes using the QGIS interface. But is this possible with Python? This link shows how to achieve the result ...
0
votes
1answer
144 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 = ...
5
votes
0answers
429 views

PyQGIS CRS on the fly reprojetion

As a first step of a pyqgis plugin I'm trying to import several shape files at once. To get them aligned, using the GUI, I'd enable on the fly reprojections and set the project crs to WGS84. I'd then ...
0
votes
0answers
64 views

detect signal where delete polygon in qgis?

I am working with QGIS and i want when i delete a polygon and then i commit this action I detect the signal of this operation and use it in python script, I tryed this but dont work: def delete(): ...
5
votes
1answer
378 views

QGis Zonal Statistics Plugin NoData included in Calculations

I have been trying to use the QGIS zonal statistics plugin. My raster has a nodata value of -99999 and all other values are positive. After computing the mean zonal statistics there are a number of ...
2
votes
1answer
643 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 ...
4
votes
1answer
357 views

How to add a layer group using pyQGIS?

Good morning, I would like to know how I can create a new group in the layer manager using python code, someone could help me?