Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
2answers
139 views

How to get the file paths of the loaded layers in a QGIS plugin?

I am very new to GIS, QGIS and Python so please bear with me. I am using QGIS 2.0 and I would like to develop a QGIS plugin that would display the raster layers of the main window in order to allow ...
0
votes
0answers
6 views

Pyqgis 2.2 : How to allow editing on layer and features

I'm writing a pyqgis plugin with qgis 2.2 I succeeded in accessing and displaying vector data (geometries & attributes). Now I would like to allow editing for all my layers and all features ...
0
votes
0answers
26 views

Modifying properties of Attributes Table in QGIS?

In my QGIS project I'm using vector layers that require a lot of data inputting/editing. The problem is that some of the data I'm inputting varies greatly in matter of length and structure (various ...
3
votes
1answer
171 views

Load and display a layer 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 ...
2
votes
1answer
35 views

How to add labeling to a polygon layer?

I'm trying to add labeling to a polygons vector layer called "myVectorLayer". It does not give me an error but the labeling does not appear. palyr = QgsPalLayerSettings() ...
0
votes
0answers
15 views

How to move a layer in QGIS Toc above an existing group?

If in QGIS TOC a group already exists and I add a new layer via QgsVectorLayer* lyr= mQGisIface->addVectorLayer(uri->uri(),Title, myProviderName); the new layer will be inserted within the ...
0
votes
2answers
104 views

How to copy attribute values of fields in selected features of one layer to another Qgis programmatically?

I am trying to get the values of attributes of the selected features of a layer field by field and copy to another layer that I created in qgis with pyqgis. Is here a example for this. Every example ...
1
vote
1answer
87 views

How can I add grid lines to a print composition using pyqgis?

I'm writing a qgis plugin to create an image in the print composer of the current map. I can get the map rendered in the proper place with a frame of the right width, and I can get grid annotations ...
2
votes
1answer
234 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
0answers
29 views

PyQGIS: Editable Combobox for Value Map widget isses

I am having issues with an editable combo box in QGIS 2.4. The edit widget is set to Value Map with an uploaded CSV. However, if a new values (not included in the key value pair list) is added, the ...
0
votes
0answers
73 views

QGIS 2.4: plugin changes map tool canvas click behavior from 2.0

I had created a plugin for QGIS 2.0 to add new features more easily. It involves changing extents and updating snapping options along with triggering the default actionAddFeature(). However, I've ...
1
vote
1answer
227 views

QGIS Updating composer label text via python - problem with Item Properties panel

I am writing a plugin that replaces the text of a composer label based on its itemID. When I change the text of the label using: item.setText("Hello World") the label changes on the composer but ...
0
votes
1answer
19 views

How I can get coordinates by clicking on the QGis Canvas with PyQGIS?

Please, does anybody knows if there are any procedure on QgsMapCanvas (pyqgis, qgis) in order to obtain a pair of coordinates by clicking on the map canvas? Are there any python code I can see?
2
votes
0answers
20 views

Add a new polygon to an existing shapefile from wkt in QGIS

I have a layer of polygons in QGIS; I want to add programatically (pyqgis) a new polygon to this layer using WKT. Example: mywkt = POLYGON ((522762 376413 0,530635 368671 0,522237 353713 0,522762 ...
0
votes
2answers
34 views

Error while importing CSV File using PyQGIS

Currently I am trying to import a CSV file using the python extension in QGIS and I have run into a problem that I can not seem to solve. I am trying to do a basic import of a CSV file from a python ...
4
votes
1answer
294 views

How to write scripts that can call on both Arcpy and PyQGIS?

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
1
vote
1answer
25 views

What causes this error when loading plugin

After installing pyspatialite on my Mac two plugins fail to load with this error:: This plugin is broken invalid literal for int() with base 10: '2-spatialite' I am fairly sure that the offending ...
0
votes
1answer
37 views

How to integrate pascal code into a QGIS model or plugin?

I have a console program that is written in pascal (lazarus) that reads in some raster files and parameter values as input. The code use dynamic 2D arrays to represent the rasters. I would like to ...
4
votes
1answer
126 views

How can I modify layer order with the QGIS python API

Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it? I use an existing QGIS ...
4
votes
1answer
133 views

Can I add entries to the layerlist context menu?

I am implementing a python based plugin for use with QGIS 1.8. Most of it's user interface is contained within a QDockWidget but there are some layer specific controls I would like to append to the ...
2
votes
2answers
125 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
3
votes
1answer
765 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 ...
0
votes
0answers
39 views

developer problem with PyQGIS

I am a QGIS developer. We have been modifying the source code of QGIS for several months and have done good work in QGIS version 2.1. After that we tried to do the same modifications for QGIS version ...
0
votes
0answers
25 views

pyQGIS : Way in order to know modifications?

I 'm writing a pyqgis script. I succeed in accessing gis vector data (lists) from my remote server (thanks to urllib) . I succed in displaying geometries and attributs. 1/ Now, i would like manage ...
0
votes
1answer
55 views

Print custom feature form using PyQGIS

I am looking for a way to print a custom feature form created in PyQt Designer for QGIS 2.4 using PyQGIS. My goal is to print/save image as the current extent of the map with the selected feature's ...
4
votes
2answers
725 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
23 views

How to read Oracle data with PyQGIS? (“identifier is not long” error)

Do you have any idea how load Oracle spatial data to QGIS with using the PyQGIS? Is it possible? I try: uri = QgsDataSourceURI() uri.setConnection("*host*", "1521", "*database*", "*username*", ...
0
votes
0answers
13 views

v.clean in QGIS Python console

I have tried to use v.clean and v.clean.advanced (by GRASS GIS) within a script in QGIS, and was not able. I followed instructions here:, but was not able to do so. I got message: "No module named ...
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 ...
1
vote
1answer
118 views

How to save after using fet.setFeatureId in pyQGIS?

By using the following code, I want to change the id of the line when saving the line. But the setFeatureId command, gives a false when doing the commitChanges(). Any idea how to change the id? vl = ...
0
votes
1answer
26 views

PyQGIS - QgsMapToolEmitPoint

I would like to make use of Signal and Slot while using PyQgis along with PyQt4. Despite spending some time trying out tutorials and some somewhat related post on gis.stackexchange I can't figure out ...
1
vote
1answer
367 views

QGis 2.0.1 mapserver extension missing

I tried to export my Qgis projects to mapserver, using RT mapserver extension, because there is not any other extension in my version of QGis.(QGis 2.0.1 Dufour on ubuntu 12.04 LTS). After installing ...
1
vote
1answer
34 views

How to interact with other layers in a QGis Python init function?

I am using QGis and making a Python script that sets the Python Init function to a custom UI file. I have a function with the following signature: def formOpen(dialog, layer, feature): ... I ...
0
votes
0answers
19 views

Error when providing “Python init function” from Python script in QGis

Problem I am using QGis and Python scripting to programmatically set a layer's edit form and "Python init function". It appears that the Python init function is called correctly in one situation ...
1
vote
1answer
51 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
6
votes
4answers
1k views

How to get features based on their attributes using Python?

How to Get features by their attributes (similar to Iqueryfilter in arcobjects) in Qgis using python? Instead of getting all features and filter it manually, is there any option to use whereclause to ...
4
votes
1answer
287 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
495 views

How to debug 'Layer is not valid error' from Python plugin?

I'm trying to understand what goes wrong with a QGIS python plugin. Basically I'm trying to render a series of POINT. The query works fine, at least giving it by hand from inside PostGIS DB: "SELECT ...
0
votes
0answers
23 views

QgsMapRenderer to export current extent using PyQGIS

I am trying to accomplish PyQGIS simple map rendering via the QGIS 2.0 Python console, but end up with only a blank image. I've followed instructions of this link. My objective is to export a simple ...
0
votes
0answers
43 views

gdal_translate from within pyqgis [duplicate]

I want to use gdal_translate from within a python script in my plugin qgis2leaf. I've tried with ...
0
votes
2answers
387 views

How to display data from a feature?

I want to display data based on the feature currently selected/clicked on. I am following a tutorial from http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html. It initially shows you how ...
1
vote
2answers
38 views

How to switch to edit mode vector layers, in pyqt application based on qgis?

I do QGIS based application, I need to implement the ability to modify the geometry of vector layers in manual mode (editing nodes), how to do it?
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 ...
0
votes
0answers
22 views

QGIS - Calling interpolation extension from python console

I would like to call the QGIS interpolation extension function (TIN method) (Raster->Interpolate) from python console. I can't find the corresponding function within QGIS API or within the ...
0
votes
1answer
44 views

How to open, modify and save a QGIS project with PYQGIS

I need to create a stand-alone script for opening a QGIS template project, modify a layer data source, export the Composition and finally save the modified .qgs project into a new file. So far I have ...
1
vote
1answer
50 views

How to programmatically export a composition as image?

QGIS Print Composer has tool "Save As Image" and I found appropriate function in QGIS source code exportCompositionAsImage. Is it possible to get access to existing Print Composer from Python console ...
2
votes
1answer
70 views

How to implement 1:n joins with string attribute concatenation?

I have a question concerning pyQGIS. I'm a QGIS long-time (self-learned) user, but just a pyQGIS newbie. I want to implement 1:n spatial join with attribute concatenation in the table. I have a vector ...
2
votes
1answer
340 views

Python Script that calls the Voronoi Polygons Function?

I've been looking to see if there was a way to call Voronoi Polygons function found in Vector/Geometry Tools, directly from the code but I have not found one. Does this currently exist? Is there a way ...
0
votes
0answers
36 views

Couldn't load PyQGIS in QGIS 2.2 on Ubuntu 14.04 [duplicate]

This issue appears to be occurring with some frequency to folks in some shape or form. I upgraded from ubuntu 12.04 to 14.04, with loss of python functionality. My QGIS version is 2.2 from the ...
0
votes
1answer
33 views

QGIS API documentation in French?

I am looking for a document which explains what the API of QGIS is, with examples of this API but in French.