Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
2answers
172 views

How to access user credentials in database connection?

I am trying to automate a couple of things when a QGIS plugin is activated: If Layer A is not in the TOC, add it. This requests username and password to access a PostGIS table using the inbuilt ...
2
votes
1answer
110 views

Which data providers support loading attribute tables without geometry?

I have a table in Memory from a cx_Oracle query (a list of rows, and a list of field names and their types) in my python plugin and I want to load it as a geometry-less layer (Attribute table) in ...
0
votes
0answers
72 views

Unable to render layers in MapCanvas using PyQGIS/PyQt4

I am trying to get some layers into a MapCanvas and style them. I am following the PyQgis Cookbook info here but my code is just not working. I've been spinning my wheels on this for over a week now ...
0
votes
1answer
131 views

Unable to load PostGIS vector layer into QGIS using python cookbook recipe

I'm having trouble loading a PostGIS layer using Dufour (from osgeo4w), using the guide at http://www.qgis.org/en/docs/pyqgis_developer_cookbook/loadlayer.html. I just get the 'invalid layer' message. ...
1
vote
0answers
59 views

How can I change the NoData value in QGIS 2.x using the python console

I'm trying to add a NoData value to a single band raster image in QGIS 2.0 using the python console but can't find the right bit of code to do it. Here's what I see on the console: >>> ...
1
vote
1answer
163 views

How to label vector features programmatically?

I am using python for QGIS 2.0.1 and I have a vector layer of points representing the positions of state labels. I want to display the 'state abbreviation' attribute on the corresponding point for ...
1
vote
2answers
174 views

Programmatically load composer from template and generate atlas using pyQgis

I Am trying to build a plugin to load a print composer from file, generate an atlas and export to image. So far I have been successful in loading the template and exporting it to image. I have been ...
2
votes
2answers
494 views

Standalone applications using QGIS and environment variables

I've tried going through IRC to see if people can help me out with this, but the medium seems a little clumsy for making any answers clear, so I'm going to try this instead. I would like to program a ...
4
votes
2answers
243 views

How do I set layer transparency in QGIS 2.0 with Python?

I have a raster layer loaded in QGIS and I'd like to be able to set its transparency via the Python console. I'm new to the API and have not been able to find out how to do this. Any help would be ...
10
votes
1answer
256 views

PyQGIS file lock release

I was wondering what triggers the release of file locks in pyQGIS? I am trying to delete a few data sources (used temporarily) by calling QgsVectorFileWriter.deleteShapeFile, but I have to quit QGIS ...
0
votes
1answer
119 views

How to perform Graduated Width Markers on Grad. Thickness Lines in QGIS with pyQGIS?

I am using QGIS + pyQGIS + Python. Layer geometry is line. Each line has a magnitude and a direction (from 1st node to 2nd node). What exactly I want to perform is "graduated width marker symbology ...
0
votes
1answer
157 views

How to zoom to the extent of Qgsvectolayer qgis?

Anyone know how to zoom to the extent of a Vectorlayer in qgis using python plugin?
0
votes
0answers
65 views

how can i read an attribute value from qgsfeature?

How can i read an attribute value from qgsfeature ? i am trying to update some attribute using other and i have to read value from attribute in the qgsfeature . my source code: provider = ...
0
votes
0answers
32 views

What is the action name in qgsinterface for the deselect feature from all the layer tool?

I want to add the deselect feature from all the layer tool in the toolbar when the qgis user start editing a vector layer. anyone know what is the name of this action in qgis api 1.8?
1
vote
1answer
125 views

How to activate a layer in QGIS layers legend

How can I activate a layer in qgis map legend automatically using python code . I am using qgis.utils.iface.setActiveLayer(self.theLayerToEdit) but the layer is still not checked in the maplegend. ...
3
votes
2answers
268 views

How to load memory output from QGIS processing?

Many processing algorithms have an option to save output as memory. If ran from toolbox, this works fine, because you can tick the "Open output file after running algorithm" box. Looking at the ...
2
votes
2answers
244 views

How to get field names in pyqgis 2.0

I am trying to change an plugin from QGIS 1.8 to 2.0. In the 1.8 version I create a table of the field names like this: layer = vlayer provider = layer.dataProvider() feat = QGSFeatrue() allAttrs = ...
1
vote
1answer
74 views

Different output from running algorithm in toolbox and from script

I am unable to get the same results when running the qgis:reproject tool from QGIS processing toolbox (QGIS version 2.0.1) as when running it from a Python script (console). In this example I am ...
2
votes
2answers
108 views

No prj file output from qgis:reproject

I'm trying to reproject a vector layer using the 'qgis:reproject' algorithm in the processing/sextante module of QGIS, from Python. This kind of works, but the .prj and .qpj files created after ...
2
votes
1answer
268 views

Using in-memory vector layer with QGIS processing / SEXTANTE

I'm trying to run the qgis:clip algorithm from console, but am getting an error when using an in-memory layer as the overlay parameter. Is this to be expected, or am I doing something wrong? Code: ...
2
votes
1answer
157 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
55 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 ...
5
votes
0answers
48 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. ...
1
vote
1answer
162 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
109 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
428 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
69 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
33 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
20 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
121 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
169 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 ...
3
votes
1answer
211 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
120 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
99 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 = ...
6
votes
2answers
504 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 ...
1
vote
1answer
99 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
161 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
119 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
70 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
83 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, ...
1
vote
1answer
841 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
102 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
120 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
276 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
100 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
677 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
48 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 ...
3
votes
2answers
198 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 ...
0
votes
2answers
205 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
757 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. ...