Python bindings for QGIS.

learn more… | top users | synonyms

0
votes
1answer
30 views

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

Is 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
1answer
25 views

PyQGIS - Start/Stop Editing with data Provider - Commiting changes

I want to edit a specific field for a QgsVectorLayer, within a QGIS application. I am facing inconsistent results from my code, ie: changes are not alway commited. Please could someone point me to ...
2
votes
2answers
133 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 ...
1
vote
1answer
43 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
2answers
141 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 ...
4
votes
1answer
142 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
2answers
311 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
30 views

QGIS 2.4 plugin PyQT qWebview javascript interface problem

I have a QGIS plugin which contains a qtwebview and javascript communication between the page and the plugin. It is working perfectly with QGIS 2.2 but not with 2.4 ( both QGIS version share the ...
2
votes
0answers
14 views

Refreshing “layer render order” widget

i made changes in the render order of my map canvas using a : qgis.utils.iface.mapCanvas().setLayerSet(a) "a" being a list of QgsMapCanvasLayer My code is working as expected (i see result on map ...
3
votes
0answers
22 views

QGIS Processing Progress

I have been developing a python plugin that uses Processing algorithm for raster calculations. I want to support the gui with progress bar. How can i connect Processing job to progress bar? I found ...
1
vote
1answer
41 views

Programmatically export a Qgis project

I have a QGis project that I programmatically modify using the Python xml.etree library. Now, I would like to know if it is possible to add few lines to my script in order to export the modified ...
3
votes
1answer
35 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 ...
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 ...
1
vote
1answer
124 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 = ...
1
vote
0answers
28 views

Retrieve a point coordinates from map canvas using QGIS API

I'm trying to build a plugin that firstly captures the map coordinates. I have tried to adapt the map tool explained in this post: How to programatically check for a mouse click in QGIS The code I ...
0
votes
2answers
418 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 ...
2
votes
0answers
18 views

Memory layer or QgsVectorFileWriter Error?

Currently this excerpt of code will not save to file (as it is supposed to). The memory layer is visable and editable. Yet even when manually saving the layer, any priorly added features ...
2
votes
1answer
24 views

QgsMapCanvas.reresh() does not reload new wfs layer features, but panning does

I have a wfs layer loaded in a standalone QGIS app, which I am updating by running a database query on the view it is based on. The feature is added with no problems and I reload the layer with: # ...
2
votes
1answer
508 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
1answer
443 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
18 views

How to set QGIS options in standalone pyqgis application

I have a standalone application which uses the QGS api to view and query map layers. One layer is a WMS-C layer which automatically caches tiles which is great. I want to also activate a setting which ...
1
vote
1answer
32 views

Import shapefile is not working in pyshp?

I am just trying to use "pyshp" package to open shapefile in Python and use the Attribute data for further development. Firstly I have downloaded pyshp package for python 2.7 and installed it in my ...
3
votes
1answer
33 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 ...
2
votes
0answers
15 views

access point layer representation in qgis with pyqgis

I am exporting the style of a categorized point layer with qgis: unfortunately my code only extract the size of the symbol in the definition of the properties of the layer but not the ...
3
votes
1answer
172 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
33 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 ...
4
votes
1answer
299 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 ...
1
vote
2answers
49 views

Pyqgis 2.2 : zoom to layer extent?

Regarding my plugin pyqgis 2.2, i can load a vector layer succesfully. But when i try to zoom to the layer extent it does not work. How to do in order to zoom to the layer extent? Thank you very ...
1
vote
0answers
16 views

PyQGIS standalone gdal_ECW_JP2ECW.dll error

This is my code in a batch file My error messages are gdal_ECW_JP2ECW.dll error unable to open EPSG support file gcs.csv Thanks in advance REM Change OSGEO4W_ROOT to point to the base install folder ...
0
votes
1answer
89 views

How to clip a raster by a shapefile in pyqgis?

Currently I am working with some satellite images (grib files) in pygis. As I want to work only with the cells in my study area, i need to clip the raster by a shapefile. I know í can do this by ...
0
votes
1answer
46 views

How to delete column/field in PyQGIS?

How to remove or delete column fields in a shape file using python?
2
votes
0answers
35 views

How to add a TIF raster layer programmatically?

This is my code whenever i try to load .tif image it shows layer is not valid,QgsRasterLayer always return invalid layer (I am using linux 12.04). QString myFileName = ...
0
votes
0answers
6 views

Pyqgis 2.2 : get signal on feature added : error message

For my pyqgis plugin 2.2, I try to: def logFeatureAdded(self,layerId,addfeatures): message = str(layerId) + " has features added: " for feature in addedFeatures: message += str( ...
0
votes
0answers
32 views

Get signal on edited feature?

Regarding my pyqgis plugin 2.2 , I've implemented signal on a vector layer event successfully. For instance, whenever i create a new feature, i can read a new basic message appeared via QGIS logging ...
0
votes
0answers
32 views

Is there a way to take control of the mouse pointer using python in QGIS?

i would like to take control of the mouse pointer in QGIS (for example constraining it to a given extent...) Is there any way to do that using PyQGIS ? Thanks !
0
votes
1answer
200 views

clip one layer with the current map layers

I work in a little companie where the main goal of employees in GIS is to have a quick view of the issues on a study area. It would be very useful to have a tool wich clip all the layers of the ...
2
votes
1answer
235 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 ...
1
vote
1answer
37 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
14 views

Pyqgis :2.2 : link between a signal and an event

I'm writing a pyqgis 2.2 plugin with qgis 2.2 I succeeded in accessing and displaying vector data (geometries & attributes). I succeed also to create a 'beforecomitechanges' signal ( emitted, ...
1
vote
2answers
146 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 ...
1
vote
0answers
32 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
205 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
52 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
19 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
127 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
93 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
265 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
36 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 ...
1
vote
1answer
230 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 ...
2
votes
0answers
26 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 ...