Python bindings for QGIS.

learn more… | top users | synonyms

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 ...
3
votes
1answer
822 views

How to use gdal_contour in QGIS Python console?

Is there a way to use the gdal_contour utility with-in the python console of qgis ? Thank you
3
votes
1answer
230 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 ...
3
votes
1answer
284 views

Is it possible to programmatically add calculated fields?

In the Memory provider described in PyQGIS Cookbook or in question How to create a new empty vector layer programmatically? I can see how to create a vector layer programmatically using standard ...
3
votes
2answers
264 views

How do I specify the position, style and units of the ScaleBar in pyqgis?

I would like to add a scale bar to my composition using the python console and then export it to a raster image. I am following the MapRendering tutorial with the "output using map composer " approach ...
3
votes
2answers
269 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 ...
3
votes
1answer
263 views

How to calculate all paired shortest path using PyQGIS?

The code for shortest path analysis with PyQGIS specifies start and end nodes explicitly: pStart = QgsPoint( -1.37144, 0.543836 ) pStop = QgsPoint( -1.1027, 0.699986 ) ...
3
votes
2answers
145 views

Merging polygons at county level to state level

I have a shapefile that represents counties (admin 2) only, but I need to create a state level (admin 1) polygon file (I'm using QGIS). I will need to sum up (or average) the relevant data at each ...
3
votes
1answer
225 views

Can I use QGIS plugins in PyQGIS as a stand alone script without iface?

Can I use a qgis plugin especially (openlayers plugin) in stand alone pyqgis script? I don't find examples, just code using iface but that cannot used in stand alone script.
3
votes
1answer
525 views

Changing attribute data types using PyQGIS

OK, so I've already asked a question how to access attribute data types when developing plugin for QGIS, using PyQGIS. And one helpful member said i should use pendingFields() method on the current ...
3
votes
1answer
33 views

How to store the CHANGES to a map database

I'm looking into providing a map amendment service for a particular map series. The service will help map owners look into the changes made to the operational features of the map, after the map was ...
3
votes
1answer
103 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 ...
3
votes
1answer
106 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 ...
3
votes
1answer
501 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 ...
3
votes
1answer
507 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 ...
3
votes
1answer
373 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
1answer
294 views

Why are the features in my memory layer not displayed?

I am trying to create a memory layer, I followed the directions from the page below but no points appeared on my map. First I tried typing each line into the python console and I also create a plugin ...
3
votes
1answer
253 views

How to move Layer to back?

from my Plugin I've loaded a rasterlayer using the following code: fileName = "/path/to/raster/file.tif" fileInfo = QFileInfo(fileName) baseName = fileInfo.baseName() rlayer = ...
3
votes
2answers
137 views

How can I read the settings for the QgsPaperItem from XML?

I saved a template qpt for the map composer and now I want to read all the settings. I am able to insert the items with composition.addItemsfromXML... But this doesn't load the settings for the ...
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 ...
3
votes
1answer
217 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 ...
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 ...
3
votes
1answer
311 views

Add attributes to vector layer with pyqgis (QGIS 2.0 API)

i am trying to make a QGIS plugin ready for the new QGIS API in the current development branch (for the upcoming QGIS 2.0 release). ...
3
votes
1answer
121 views

How to see print commands through Python Script while programming plugin for QGIS?

This might sound like a silly question. Is there a way that from running a custom plugin made for QGIS that a Python Shell can appear along when the plugin is run, like a debug screen. I'm asking ...
3
votes
1answer
120 views

How to auto-start a pyQGIS thread?

having build some (two) minor plugins, it's now time for me to link a few (perl-) applications to qgis. As there is no perl-interface in qgis I thought the best way to link both worlds together is a ...
3
votes
1answer
221 views

Join GPS points obtained from .GPX file in Python Console

Having loaded the .gpx file into a new layer from python console, I'm unable to access the gps points in the attributes table. Essentially, i'm unable to join these points to form a polygon ...
3
votes
1answer
119 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 ...
3
votes
1answer
383 views

Creating Selection MapTool in PyQgis Custom Application

I'm developing a custom GIS application using PyQgis API. How can I let the user select features on the map using Maptools? I would like to replicate the select feature there in Qgis to make the ...
3
votes
1answer
962 views

QGIS: How to load feature (.qml) styles from python? [duplicate]

Possible Duplicate: How to style a layer from console? I'm trying to set the styles for a vector layer by loading the .qml file in the python console. The qml-style file contains all ...
3
votes
1answer
140 views

How to display a particular area?

Hy, I'm developing a plugin in python for Qgis. I would like the user to select a particular area in a list (let say a country list) and zoom in the map on the corresponding area. Actually I'm ...
3
votes
1answer
169 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 ...
2
votes
3answers
402 views

How to find the polygon inside which a point lies?

I have a layer with polygonal features. Each feature has attributes and values. I also have a list of co-ordinates and I would like to know which feature (or polygon) the co-ordinates lie in. Could ...
2
votes
1answer
99 views

How to get a message when the map is moved in QGIS?

I want to get a message when every time I move the map. I had: def info(self): QMessageBox.information( self, self.tr( "Info" ), self.tr("info") ) I suppose that used to be something like ...
2
votes
1answer
671 views

How to apply a graduated renderer in pyQGIS?

Just trying to run the following code already given in the pyqgis cookbook to create graduated colors symbology (as in example with 2 classes) I define the source info for the shapefile but when I ...
2
votes
2answers
1k views

How to access attribute data type in QGIS?

I've been developing a plugin on QGIS platform using PyQGIS. So far plugin does the following: You can select any feature of the already loaded vector layer in QGIS. After selection, plugin displays ...
2
votes
1answer
134 views

How to update data from external table in real time?

I have been trying for a long time to connect a external table data[csv] through Excel (for exmaple) with QGis with the objective to each time i change any data in table(for example data location - ...
2
votes
3answers
427 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 ...
2
votes
1answer
76 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
249 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 = ...
2
votes
2answers
433 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
217 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
123 views

How to get mean of pixel values within a buffer zone around current mouse position in QGIS

for a qgis 1.8 python plugin I want to query the mean of all pixel values of a raster layer within a defined buffer around the current mouse position, not for an existing point layer. For the buffer ...
2
votes
1answer
650 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
2answers
934 views

How can I specify the CRS of a raster layer in pyqgis?

I manipulating netcdf raster data from the QGIS python console. The metadata of my netcdf file does not provide the Reference system. However I know it is 'EPSG:4326' I am writing a python script to ...
2
votes
1answer
110 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
2answers
77 views

How can I close the identify result dialog programmatically?

I am trying to close the identify result dialog which appeared when I select to identify a feature from the active layer. Does someone know how can I do it?
2
votes
2answers
501 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
89 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 ...
2
votes
1answer
162 views

How to store attributes of a large shapefile in a list?

I am trying to store the attributes of a shapefile into a list. With following code it works for smaller shapes: addA = [] While provider.nextFeature(feat): attrs = feat.attributeMap() for ...
2
votes
2answers
645 views

Creating QGIS layers in python console vs stand-alone application

I am having trouble creating a QGIS vector layer in a stand-alone python script while exactly the same code works fine in python console inside QGIS. The following code results in a proper ...