Python bindings for QGIS.

learn more… | top users | synonyms

8
votes
1answer
1k views

How to draw perpendicular lines in QGIS?

I have a situation like this: What I need to do is to connect each point to every line that is at most, let's say 200 m, away from the point. In other words, I need to draw a perpendicular line ...
10
votes
1answer
872 views

Is there a way to access QGIS plugins in Python?

Is there a way to access QGIS plugins in Python? I'd like to write a script to do some geoprocessing, and I'd like to use the clip, regular points and convex hull tools in fTools, as well as the Road ...
1
vote
1answer
786 views

How to evaluate raster calculator expressions from the console?

How can I execute from the console an expression that should be used with the raster calculator? I'm searching for something like this: qgis.someRasterCalcClass.evaluate("boh@1 + boh@2", ...
3
votes
1answer
758 views

Get a pixel value

How can i do this operation: I want to get a pixel value fro the satellite image (Landat, GeoTIFF, 7 bands) using qgis-python. What operators should i use? (for example in qgis's Python Console) ...
4
votes
2answers
688 views

How to automatically reloaded raster layer if source is changed in QGIS?

How to automatically reloaded raster layer if source is changed? (The path is the same but inside source file are changes) I use: qgis.utils.iface.mapCanvas().refresh() but layer not refresh. # ...
11
votes
2answers
3k views

How to create a new empty vector layer programmatically?

I am new to python and QGIS. I have looked at a few tutorials of python scripts for QGIS. All of them create new vector and raster layers with some existing data source. eg. shapefile or geotiff or ...
8
votes
1answer
381 views

How to address the new “Task-Completed” QgsMessageBar in Python?

I am really amazed what huge steps the QGIS development has taken in the last months. The new iconset, the improved Print composer and many more changes to be seen in QGIS 2.0 are really awesome! ...
2
votes
3answers
594 views

How to add QGIS Python API Intellisense support in Aptana Studio3/Pydev

I'm developing QGIS plugins using PyDev in Aptana Studio 3 and I would like to know if it's possible to make it aware of the QGIS API and add some "intellisense" functionnalities when programming. For ...
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 ...
4
votes
2answers
768 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 ...
3
votes
1answer
492 views

Getting dataProvider from vector layer outside QGIS

I'm using PyScripter to explore PyQGIS API because of it's very handy auto-completion function. I've managed to get a handle on a PostGis vector layer by: >>> from qgis.core import * ...
3
votes
2answers
387 views

Rendering and Labeling Shapefile with PyQGIS

I've been running into a few problems working with the QGIS API for python. I've gotten more comfortable working in the python console in QGIS but I run into problems when I try to run the code ...
1
vote
2answers
362 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 ...
1
vote
1answer
815 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. ...
9
votes
1answer
2k views

When iterating over a vector layer with pyqgis, how do I check whether a feature is selected?

While iterating over a vector layer using the following code (summerized from the example in the pyqgis cookbook), is there a way to check whether a feature is selected? provider = ...
4
votes
2answers
1k 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 ...
2
votes
1answer
738 views

qgis.core import error

I would want to use the Qgis api for custom desktop application. When I imported the qgis.core module, I get the following error >>> import qgis.core Traceback (most recent call last): ...
2
votes
1answer
214 views

How can i include program form (created in Designer ) to my QGIS plugin?

How can I include a form created in Designer in my QGIS plugin? And how to get controls values (textbox,label,etc)?
0
votes
1answer
66 views

Halt QGIS on startup

I have a custom made login form in Python, which launches on QGIS startup. But before the user has a chance to enter the credentials, the program starts normally, bypassing the form. From then on the ...
0
votes
1answer
196 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 ...
0
votes
1answer
312 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 ...
8
votes
1answer
840 views

How to add a toolbar via python?

Through tutorials I learned how to add a toolbutton to the plugins-toolbar via python. Now I wonder how to add a complete toolbar with toolbarbuttons via python. Can anybody give some example-code? ...
5
votes
1answer
968 views

How to transform a selected multipart feature into singlepart features while editing in QGIS?

There are several questions and respective answers for how to make a multipart features Layer into a singlepart features one using QGIS: How to break a single polygon into multiple polys? How to ...
3
votes
1answer
750 views

How to find the nearest line to a point in QGIS? [duplicate]

My question is that given a point and few lines, how should I go about finding the nearest line to the point? I am aware of How to I find the nearest line to a point?, but that isin ArcGIS and ...
2
votes
1answer
495 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
555 views

Joining table to shapefile with pyQGIS

Joining shapefiles is a relatively straightforward proess in QGIS using 'add vector join' in the layer properties menu. I can add a csv file as a vector layer, as well as a shapefile, and join the two ...
1
vote
1answer
139 views

How to add the attributes of selected features to my new layer in pyqgis

I am trying to create a layer from the selected points coordinates. I am drawing a circle to the coordinate of selected points. I also need to add initial attributes of my selected features to my new ...
5
votes
1answer
400 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 ...
5
votes
2answers
1k views

How do I use QGIS python console to iterate through simple layer queries and png outputs?

I'm really new to QGIS coding and I'm having a hard time finding (especially) the api classes/functions to carry out actions of the Query Builder window. I'm basically trying to do this: Iterate ...
5
votes
1answer
1k views

How can I Setup Python to recognize QGIS

I want to use QGIS and work with Python out of the console, but I'm having troubles letting the system recognize the paths of some DLLs. Since I couldn't find a good answer on the web, I wonder if I ...
5
votes
1answer
433 views

How to call GRASS modules in pyQGIS?

I wish to use a Grass module (v.to.db) in QGis, without the grass toolbox. I tried with the Python console, but to no avail : Using Sextante plugin but obviously it didn't know all the grass ...
5
votes
1answer
1k views

Why can't I import my script from the python console?

i am working with the qgis python console. I usually store all my python scripts into ~/Scripts/python I do have set the PYTHONPATH to ~/Scripts/python in my .bashrc However, I can not manage to ...
4
votes
1answer
723 views

How to deploy a QGIS Python Standalone Application with minimum installation size?

I am trying to create a Standalone QGis Application using python. I was able to create the nice looking shapeviewer application by following the steps here. Now I would like to deploy this in ...
4
votes
1answer
261 views

Personal shell launcher for PyQGIS

I have changed a shell launcher found at http://inasafe.linfiniti.com/html/id/developer-docs/platform_windows.html as to fit my wish: setting the system environment variables to be able to use PyQGIS ...
3
votes
1answer
209 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 ...
3
votes
1answer
474 views

Handle add new feature event and/or access feature before commit?

Is it possible with PyQGIS to catch "add new feature" event before commiting changes on the layer? or at least to access new features before commit.
3
votes
1answer
132 views

Button to add a new line in a non-spatial table without opening the table itself using QGIS?

While using QGIS and having loaded a non spatial table (from PostGIS), is it possible to add a new row to its table attributes without having to open the attribute table first as in here Is it ...
2
votes
1answer
131 views

Why does writing large shapefiles crash QGIS?

I'm trying to write large shapefiles with QGIS 2.0 API, using Python, which crashes QGIS. The data is composed of simple two point lines and a data table of five columns. A thousand features or so ...
2
votes
1answer
131 views

How do I access QGIS program settings programmatically?

I am trying to temporarily enable the option in QGIS using PyQt4 to suppress the attribute dialog popup after a feature is added. I found an example in the cookbook but it doesn't indicate how to get ...
2
votes
2answers
377 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
759 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 ...
2
votes
2answers
291 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
521 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 ...
1
vote
3answers
233 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 ...
1
vote
2answers
276 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
1answer
448 views

How to read the attribute values using pyQgis?

What is the way to get the information contained in the attribute table, say in column 2, row 2 using pyQgis?
10
votes
1answer
322 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 ...
9
votes
4answers
1k views

How to buffer in pyQGIS?

I'm looking for some examples to do simple python scripts in QGIS. How would I do a buffer analysis on a dataset? I can't seem to find much in the manual and QGIS python that quite matches the Esri ...
8
votes
1answer
2k views

How do I maintain a resposive GUI using QThread with PyQGIS

I have been developing some batch processing tools as python plugins for QGIS 1.8. I have found that while my tools are running the GUI becomes non-responsive. The general wisdom is that the work ...
7
votes
1answer
165 views

Unable to load .gpx file from Python Console

I'm trying to create a plugin which will extract the gpx files and load them onto the active layer window in QGIS. While I'm able to load it using the QGIS GUI from Layer>New Vector Layer, I'm not ...