Python bindings for QGIS.

learn more… | top users | synonyms

11
votes
1answer
374 views

How to create text labels with background boxes?

I'm trying to create some custom labels for point features in a QGIS point vector layer, and I want to write a python plugin to do it. We need our labels to be presented with color tinted rectangles ...
10
votes
1answer
259 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 ...
9
votes
1answer
745 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 ...
8
votes
1answer
720 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 ...
8
votes
1answer
429 views

Is it possible to show our custom message in QGIS Status bar using python?

Is there any way to show our custom message in Qgis Status bar using python? Just like in arcgis "IApplication.statusbar.message(0) = "Please wait..." like that is there any option to show ...
8
votes
4answers
1k views

How to run sextante algorithms outside of qgis python console?

I'm kind of stuck trying to figure out the way to run sextante from a standalone python from OSGeo4W distribution. The reason I want to do this is that I got tired entering parameters in the dialog ...
8
votes
2answers
2k 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 ...
7
votes
1answer
143 views

How to save python session in QGIS?

After running a lot of scripts in QGIS' python console, I have more than 10 dictionaries and lists, and I need these for further analysis. Is there a way to save python session, with all these ...
7
votes
1answer
313 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! ...
7
votes
2answers
113 views

How do you obtain the execution times of processes in qgis?

I am working on QGIS. I need to determine how much time QGIS needed to finish a specific task. I have been unable to get execution times for the processes. What is the proper way to get processing ...
7
votes
1answer
154 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 ...
6
votes
3answers
350 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 ...
6
votes
1answer
664 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? ...
6
votes
1answer
1k 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 = ...
6
votes
2answers
512 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 ...
6
votes
1answer
1k 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 ...
5
votes
1answer
663 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 ...
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
443 views

How do I allow users to select features with the mouse?

I am using PyQGis API to create a custom application. How do I allow users to select features with the mouse? Is there a mapTool for this? Surely with a product as powerful as QGis there must be. ...
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 ...
5
votes
1answer
478 views

Speed of editing attributes in QGIS from a Python plugin

I'm trying to edit the value of an attribute for each feature in a layer using a QGIS Python plugin. I've found that doing this outside of editing mode is much slower than while editing (even ...
5
votes
1answer
926 views

How can I programatically create and add features to a memory layer in QGIS 1.9?

I had a working plugin in QGIS 1.8 which read data from an MSAccess database and added it to a series of memory layers. There is some processing involved in the interim so I don't think simply using ...
5
votes
4answers
645 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 ...
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
472 views

How to get pixel size/cell size of raster layer?

After much searching, I've still not been able to figure out how to perform what seems like a simple function: I'd like to get the pixel size/cell size of a raster layer using PyQgis. Is there any ...
5
votes
1answer
308 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
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. ...
4
votes
2answers
150 views

Using Python and open source modules, how can I perform Raster Calculator functions?

I would like to perform mathematical functions similar to those you would use Raster Calculator for in ArcMap, however I'd like to do it in Python without using the Arcpy module. I have the osgeo ...
4
votes
2answers
558 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. # ...
4
votes
1answer
1k views

How can i obtain the data of one selected feature in QGIS using python?

I have a problem / question regarding python and QGIS. Is it, and yes how, possible to get the data of one selected feature in QGIS using python? In my example I have a layer which shows some parcels ...
4
votes
4answers
310 views

How to display a “Save As” dialog for raster files?

I'm writing a QGIS plugin in python. I need to show a "Save as" dialog window in order to allow the user to select the path of the output raster file. Do I need to create a QFileDialog and manually ...
4
votes
2answers
595 views

How do I get the path of a project, or layer file in PyQGIS?

I am generating new raster files from vector layers on a project. I would like to save them in the same directory as the project or layer files. How do I find this path using PyQGIS?
4
votes
1answer
787 views

How to find all intersections and count lines arriving at each intersection?

I'm having a hard time getting off the ground with this, and am trying to move away from ArcGIS / arcpy. I have a shapefile with a network of polylines. I want to find/count all 2-way intersections, ...
4
votes
1answer
542 views

How can I add OpenLayers layer from the python console?

I am new to the python console. How can I add a layer from the OpenLayers plugin from the python console? Thank you
4
votes
2answers
244 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 ...
4
votes
2answers
487 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 ...
4
votes
1answer
199 views

How change border line to no pen with python console?

From Python console I load a shapefile with qgis.utils.iface.addVectorLayer. How I can remove border lines (change to no pen) in the active layer?
4
votes
1answer
347 views

How to Create a raster layer from a numpy array using pyqgis?

I am working on a plugin for Qgis to calculate spatial Kernel density maps. I have all the calculations working, all I am missing is a way to turn a Numpy Array, with density values into a multiband ...
4
votes
1answer
229 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 ...
4
votes
1answer
111 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 ...
4
votes
2answers
257 views

How to iterate over selected layers?

In QGis by pressing shift or ctrl keys a user can select multiple layers in toc. How can a python script iterate over selected layers? I'd expect a iface.selectedLayers() but I can find only ...
4
votes
0answers
65 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
0answers
222 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 ...
4
votes
0answers
97 views

Is there a way to run the spatial query plugin from QGIS python console? [duplicate]

I want to get all contiguous polygons for every county. In QGIS I can do this manually with a Spatial Query, but for a large data set this result impractical. Is there a way to run the spatial query ...
3
votes
1answer
625 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) ...
3
votes
2answers
185 views

How to write an equivalent to MapBasic's CreateLine in pyQGIS?

I know this kind of question has been asked, in part, before - specifically: Seeing QGIS Python Commands and: How is object created as line using createline stored in .tab file? but this is a specific ...
3
votes
1answer
461 views

Get extents of vector shape features in python

i am just wondering if it is possible to iterate through vector features and return the extent per feature without clipping the vector shape? The code looks like this and comes from the ...
3
votes
1answer
184 views

How to apply a color gradient to a shapefile from QGIS console?

Anyone knows how to do a color gradient from the console to a shape file in Qgis (orin Python)? Like the image below.
3
votes
1answer
220 views

How to generate a grid programmatically in Python without GUI?

Is there a QGIS Python binding for generating a grid programmatically without using the GUI?