Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
1answer
212 views

Select by SQL in QGIS Python

In the GUI there is the Query Builder, but that does not seem to be easily available in Python. The processing (SEXTANTE) module has the qgis:selectbyattribute algorithm, but that only supports ...
1
vote
0answers
61 views

PyQGIS - Converting WKB to String

Using PyQGIS, i'd like to print the string representation of a point WKB (like what PostGIS displays in geometry columns). For example: p = QgsGeometry.fromPoint(QgsPoint(2, 4)) wkb = p.asWkb() print ...
4
votes
0answers
53 views

Using QGIS plugins from Python [duplicate]

Is there a simple way to automate calls to QGIS plugins from a QGIS Python script? Either from console or a plugin? I am ideally looking for a way to specify input/output parameters and bypass GUI. ...
2
votes
1answer
230 views

pyQgis in stand alone script, vector loading error

I am trying to use the Qgis functions in a stand alone Python script. I m running Mountain Lion OS, 2.7 Python & the Qgis 2.0.1 Dufour. My main problem is that I cannot get started - I cannot ...
3
votes
1answer
144 views

How to set and configure a value relation edittype in QGIS 2.0?

I am trying to set the edit type of a vector layer to use a value relation. The Python commands below are processed without errors or warnings, but the when I check the properties in QGIS, only the ...
2
votes
2answers
659 views

how to for loop a folder to batch clip rasters by polygon using python and QGIS

I am using python and QGIS 2.0. I am trying to clip rasters in a folder by one polygon feature. It's the first time for me using (let's say) "PyQGIS", I was used to arcpy before. Anyway, I don't get ...
1
vote
1answer
97 views

Setting the PyQGIS Maptool

I apologize if this question was already answered, but I found a lot of examples on how to set the QGIS maptool in a application from scratch, but not inside QGIS (in a plugin). In the examples I ...
1
vote
0answers
49 views

How to calculate an expression for a field using PyQgis?

I'm beginner user of PyQGIS. I would like to create one button to calculate one expression for example the relative frequencies for each field. How can i do it? Thanks for your help. Best regards. ...
0
votes
0answers
24 views

How to SUM the fields selected in aqlistwidget using PyQgis?

I'm beginner user of PyQGIS and I'm trying to write my first plugin(API 2.0). In my ui file I created a qcombobox to select a layer, and a qlistwidget to select one or more than one fields (x,y,..). ...
1
vote
0answers
186 views

Unable to use pyQGiS in a custom application - import arcgis.core error

I'm using windows 7 and/or 8 64 bit with QGiS 2.01. I'm wanting to us the pyQGiS tools in a custom python application outside of the QGiS environment (i.e by running a python executable located in ...
2
votes
1answer
274 views

How to create a QGIS action which copies features between layers?

i tried (i never tried before...) to write a simple python code like action in QGIS on my "XXX" vector layer that: open a layer "YYY" copy the selected feature on my "XXX"layer paste the selected ...
4
votes
1answer
355 views

Using the Processing Framework in QGIS 2.0

I am writing a plugin for QGIS 2.0, and I want to use the processing framework to call some functions. When I open the pyhton console inside QGIS, I am able to call it like this: >> import ...
1
vote
1answer
134 views

How can I add a delete button to feature forms?

I have created some formulars in QTDesigner for capturing and manipulating data in QGIS. The data is stored in a postgis-database. It would be helpful to have a delete-button in this formulars to ...
1
vote
0answers
112 views

Different result featureCount() on QgsVectorLayer QGIS 1.8 vs QGIS 2.0?

I use the following code in a layer action: <uri definition etc> sql = 'id = "[% "id" %]"'; uri.setSql(sql); layername = 'TableName [% "id" %]'; vlayer = ...
7
votes
2answers
812 views

Split a feature when intersecting with a feature of another layer using PyQGIS/Python?

I have a buffer layer (green polygon) which I want to split to two polygons whenever it crosses a barrier (blue line). I have been trying to use "splitGeometry" method, but I just can't get it to ...
2
votes
1answer
130 views

How to load a memory layer into map canvas an zoom to it with pyQGIS?

I would like to load a vector memory layer into the map canvas with pyQGIS. Background is, I create a memory buffer layer around point data. While iterating the points I would like to visualize the ...
3
votes
1answer
205 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
146 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
81 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
111 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
137 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
137 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 ...
2
votes
1answer
324 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
128 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!
2
votes
1answer
1k 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? ...
0
votes
0answers
67 views

How to set option that opens results of identification tool in form using python in QGIS plugin?

I would like to set "Open a feature form, if a single feature is indetified" when I run my python QGIS plugin? Is it possible? I am developing plugin for users without GIS and QGIS experience. I ...
4
votes
2answers
252 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
293 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 ...
1
vote
1answer
804 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. ...
1
vote
1answer
80 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 ...
0
votes
0answers
98 views

How to create a Layer from a list of points in PyQgis

I`ve developed an algorithm that generated an two dimensional array with points. Each subList of this array must be displayed as an polygon on the map view, and the recently created Vectors should be ...
3
votes
1answer
121 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
144 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?
4
votes
2answers
273 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
171 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
418 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
102 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, ...
4
votes
2answers
723 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
94 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 ...
0
votes
2answers
262 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
66 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
149 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 ...
0
votes
0answers
16 views

Problems loading PyQGIS Español [duplicate]

No se pudo cargar PyQGIS. El soporte para Python estará deshabilitado. Traceback (most recent call last): File "", line 1, in RuntimeError: the sip module implements API v9.0 to v9.2 but the ...
2
votes
0answers
164 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
34 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 ...
0
votes
0answers
18 views

QGIS & python: returning value from shapefile dbf [duplicate]

I'm trying to work out the python code in QGIS to return a value from a shapefile dbf. E.g. if I have a shapefile named "vlayer" how would I find the value in row 0, field 3? Sorry for such a basic ...
2
votes
1answer
109 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
234 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 ...
2
votes
2answers
89 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 ...