Python bindings for QGIS.

learn more… | top users | synonyms

3
votes
1answer
46 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
734 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: ...
3
votes
1answer
165 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
577 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
153 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
489 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
518 views

How to load a postgres view using pyQgis?

Under Qgis 1.8 on Windows 7 I have this problem with my pyArchInit plugin: I need to load on the map canvas my geometries from a postgis layer. Till the 1.7.4 version I use the method explained on the ...
3
votes
1answer
331 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
162 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
2answers
63 views

PyQGIS: Speed up for adding features and attribute arrays?

Context: I'm writing a dynamic import tool for QGIS (2.2 to 2.5) with python. Datatype: Binary Datasets with environmental simulations from HPC which might contain millions of features and terabytes ...
3
votes
1answer
58 views

PyQGIS esri ascii grid to .bil conversion

Esri ASCII GRID can be converted to esri .bil format by following way in a desktop From QGIS desktop menu-->Raster-->conversion-->Translate(convert format) How can I write a python code because I have ...
3
votes
1answer
36 views

Why is the SelectionChanged signal triggered every time i click on the layer?

i'm making some experiments with the SelectionChanged signal of a QgsVectorLayer. i try this piece of code : curLayer.selectionChanged.connect(self.test) and "test" print a warning message. The ...
3
votes
1answer
139 views

Programmatically change layer position in the table of contents (QGIS)

I am trying move/position a layer to the bottom of the TOC by using addTopLevelItem on all other layers. I unsure how to reference the layers as QTreeWidgetItem's. def bg_bottom_level_item(self): ...
3
votes
1answer
179 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
328 views

How to add a layer group using pyQGIS?

Good morning, I would like to know how I can create a new group in the layer manager using python code, someone could help me?
3
votes
1answer
682 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
197 views

How to create a line layer which connects a point layer to a line layer?

In the map shown below, I have manually created the dummy lines (in green). Using python, and without using PostGIS or sextante, I would like to automate the creation of these dummy links between a ...
3
votes
1answer
193 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
579 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
261 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
545 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
2k 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
151 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
0answers
60 views

Find Polygon in “Layer A” containing Polygon in “Layer B”

I haven't found yet someone with the same problem, so I'm posting a new question. The topic seems quite standard, so I'm sure there's a way to do it in QGIS. I have two layers: Region Layer Postcode ...
3
votes
0answers
68 views

Problem with performance when loading PostGIS layer using pyQGIS

I'm having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this: uri1 = qgis.core.QgsDataSourceURI() uri1.setConnection(str(host), str(port), ...
3
votes
0answers
91 views

Performing buffering and intersection with script in PyQGIS

I wrote a script that performs the intersection of two layers: The first Layer -> layer1, represents the rivers The second Layer -> layer2, represents a set of circular dots distributed in a ...
3
votes
1answer
46 views

Changing attribute values in a memory layer

I'm trying to change attribute values in a memory layer. My memory layer is defined in this way: pro.addAttributes([QgsField("nom", QVariant.String), QgsField("valeur", QVariant.Int)]) I made ...
3
votes
2answers
166 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
2answers
632 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 ...
3
votes
1answer
938 views

legend groups and layer position/order qgis 1.8

I'm tring to programmatically create layer sequence also using groups. Simple python code: layer = QgsVectorLayer("004cp000.shp", "004cp000", "ogr") QgsMapLayerRegistry.instance().addMapLayer(layer) ...
2
votes
1answer
1k 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
1answer
177 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
2answers
2k 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
2answers
92 views

Is there function to know raster's size (KB) with python?

I am doing a script with python. There I have many raster in canvas (qgis) which I would like to know size in MB. I am searching function in python that give me this result. Anyone can help me? Thank ...
2
votes
2answers
640 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
1answer
233 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
730 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
2answers
115 views

Programatically use Openlayers plugin layer in Print Composer

I created some PyQGIS functions to set up a print composer, modify the layout (adding maps, legend, title...) and print the result as an image file. This works fine with one or several vector layers - ...
2
votes
2answers
60 views

How to programmatically create nested layer groups?

Using PyQGIS via the QGIS 2.4.0 Python console and the editor, I can create parallel groups for storing some layers with: MyFirstGroup = iface.legendInterface().addGroup('Group No. 1') MySecondGroup ...
2
votes
2answers
86 views

How to open the “File Browse” dialog in Windows from a PyQGIS plugin code?

I am in the process of developing a plugin for QGIS using Python. Note that this is my first plugin, so the query could be quite basic... I have used this Digital Geography link to create the basic ...
2
votes
4answers
94 views

QGIS Plugin with save settings dialog

I am writing on an update of the qgis2leaf plugin. It would be great to store the settings of the plugin UI (like which checkboxes are checked, which strings are used) in a separate file (like xml or ...
2
votes
2answers
106 views

How to remove/disable a toolbar via python?

How do I remove or disable a toolbar e.g., Raster, programmatically using Python?
2
votes
1answer
227 views

Got Null values when updating attributes with PyQgis

I'm trying to create and update a field and ,for now, just change it's value to 2. Here is my code: layer = qgis.utils.iface.activeLayer() index = layer.fieldNameIndex("P") # if index == -1: # ...
2
votes
1answer
170 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
431 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 ...
2
votes
1answer
212 views

Pyqgis vector layer rollback and commitChanges

I have problems with the vector layer rollback and commitChanges function, it doesn't matter wich one i call the vector layer is is Changed.Here is my code i hope someone can help me. This is my firt ...
2
votes
2answers
349 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
181 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
366 views

Understanding the QGIS API documentation to write python code

I am not sure how to use the API documentation to code in Python. For example, I want to determine whether a layer is a point, line or polygon layer and found the following in the API documentation: ...
2
votes
1answer
207 views

How to begin with tool development for GRASS gis or QGIS GRASS

I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...