Python bindings for QGIS.

learn more… | top users | synonyms

2
votes
0answers
52 views

How to get user and password of a PostGIS layer

I wonder if it is possible to get the user and password for a PostGIS database if they are stored in the PostGis connection information. I get the connection information at the moment from the ...
2
votes
2answers
60 views

QGIS layer tree API returns only groups and not layers

I am trying to use the QGIS python API to read out the groups and layers in a QGIS (2.4) project. Here is a code snippet from my script, which is run from a shell, not from the QGIS python console! ...
2
votes
0answers
42 views

How setup python path in my ide to recognize QGIS API

I'm using Intellij with python plugin. Classpath for python contains $QGIS/apps/qgis/python but my ide not recognize eg. QgsVectorLayer. Any additional entry is required?
2
votes
0answers
75 views

Setting up pycharm and pyqgis

I wanted to set up PyCharm the way this blog post explains: Setting up PyCharm for PyQGIS and Qt. I did everything as instructed but when it comes to adding project interpreters I got this error ...
1
vote
0answers
41 views

PyQGIS add WMS layer with CQL_FILTER

Dear PyQgis developers! I'd like to add a wms layer through my QGIS plugin with custom CQL_FILTER parameters. My problem is, that the CQL_FILTER parameters are not passed to the GeoServer (I can see ...
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 ...
1
vote
1answer
30 views

Pyqgis How to merge all the active layers? or layers in the registry?

I was wondering if there is a way to merge multiple layers. I actually would like to merge all layers in the registry programmatically, all of them are point layers and have the same fields. I have ...
1
vote
1answer
62 views

WMS layer in a QGIS 2.4 stand alone Python script

What is the best way to add a WMS layer on a map, in a stand-alone python script with QGIS 2.4? The methodology explained at the bottom of the official QGIS documentation page seems to be outdated and ...
4
votes
1answer
48 views

Loading same layers every time

I recently started using Qgis python console for Qgis development. My first task is to load the layer and print its attributes.I firstly load a point layer using code mylr = ...
2
votes
1answer
37 views

How to define QgsVectorLayer by QDomNode?

I am using QGIS 2.4, Python 2.7.5, win 8.1. I am trying to read layers from QGIS project. When I try define QgsVectorLayer using QDomNode and readXML function, following error appears: ...
0
votes
0answers
58 views

Python trainings comparison

My employer provides me with a generous annual training budget and I'd like to use it on one of the following two Python courses. As a GIScientist, I would like to attend the course which will give ...
1
vote
0answers
52 views

How to change color ramp in graduated classification with standard deviation using pyqgis

I'm using graduated clasiffication with standard deviation to style my shapefile (see code below). But I need to use different color ramp for classes below mean (-1std, -2std etc.).I'm thinking of ...
2
votes
2answers
49 views

No plugin icon in the toolbox in QGis 2.4

When i'm loading my plugin into QGis 2.4 the icon doesn't appear in the toolbar. There is only an empty button. I have the icon.png in all the necessary files: resources.py: <RCC> ...
2
votes
1answer
90 views

How to make serial maps from template?

I have developed a stand-alone python script for making serial maps using PyQGIS library. The maps should follow a specific format that is indicated by a template .qpt file. This template file is ...
2
votes
1answer
35 views

How to Raster Layer checked status change?

I make plugin with use QListWidget. Items of QListWidget is Raster Layer name. When selected items, same name layer checked status changing. current my code is items = ...
2
votes
2answers
76 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 ...
1
vote
0answers
66 views

QGIS Add WMS layer with python

I'm developing a stand alone python script using QGIS 2.2.0 libraries. I want to add a WMS base layer to my map, and I follow the instructions reported by the documentation: urlWithParams = ...
1
vote
0answers
24 views

PyQGIS: Properly trigger actionPan() tool when feature is added

I wrote a plugin which creates a custom map tool that adds features. I would like to cleanly connect to the pan tool after a feature is added. I've done it in the following way and it works, but I get ...
2
votes
4answers
90 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
1answer
68 views

Loading features attributes into numpy array

I am currently working on an add-on that relies on the user choosing fields of tables (that can be from shapefiles, csv or dbf) that are open in QGIS and then making computations with such data. ...
0
votes
0answers
45 views

How to manage two map items in a QGIS composition with python?

I need to manage two different map items in the same map composition, with a stand alone python script. Each composer map has been referenced like this: composerMap1 = ...
2
votes
1answer
65 views

How to get into the Python API of QGIS?

After a few hours I am about to give up on finding a kind of documentation for the QGIS Python API that actually works/gives the correct information. It is obvious that there is no actual code ...
1
vote
0answers
48 views

QGIS processing framework SAGA NaturalNeighbor in external Python Script - No Output

I want to build a little script, which generates a NaturalNeighbor grid based on a point Shapefile. The script runs within my PyDev environment without any error messages, but no outputfile is ...
1
vote
0answers
30 views

Create “grid” of polygons with the same 3D area based on an underlying raster variable (e.g. DTM height)

This could apply to point or raster values but imagine a raster of a continuous variable such as height (DTM). Is there a way to create a complete coverage of polygons that will have an equal area, ...
3
votes
0answers
47 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 ...
2
votes
2answers
47 views

Problem with accessing the layer legend using pyqgis in QGIS 2.4

I'm trying to clear the layer selection using pyqgis. It appears to me that: lgd = iface.mainWindow().findChild(QtGui.QTreeWidget, "theMapLegend") Doesn't work in QGIS 2.4 to access the layer ...
1
vote
0answers
25 views

Pyqgis, Plugin development issues

I am new in the pyqgis world... I am trying to adapt the Geocoding Plugin developed by Alessandro Pasotti to a new plugin. I have been dealing with the following issues and I think you have the ...
1
vote
0answers
34 views

ERROR 6: EPSG PCS/GCS code error when running QgsGeometryAnalyzer().buffer

I am trying to buffer points from a FileGDB in a PyQGIS script. I setup my environment with the following batch file and run the python script below. The problem is that I get ERROR 6: EPSG ...
0
votes
0answers
21 views

Problem with Performance when accessing selected Features from PostGIS layers in QGIS using Python

I have 2 PostGIS layer in my QGIS project. They have about the same amount of data and a similar structure except that layerX has its PK on a single column and layerY has its PK on 4 columns. When I ...
0
votes
0answers
65 views

How to correctly render a raster Layer to GTiFF with QGIS python console?

I am trying to render a map from a raster layer. As recommended in pyqgis cookbook and here(osgeo.org) I use QgsMapRenderer(). I am able to produce a picture but it has not appropriate extent and ...
1
vote
1answer
69 views

How to properly import QImage from PyQt4.QtGui?

I am starting with QGIS python console. Naturally, I came across the PyQGIS Developer Cookbook. While trying to cut my way through it, I encountered a lot of problems with "undefined attributes and ...
1
vote
1answer
47 views

Rotating geometry to specific angle using pyqgis?

I do not know how to rotate a geometry using pyqgis. Is there any sample/example code available to show me how?
3
votes
0answers
64 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), ...
1
vote
0answers
229 views

Ubuntu 14.04 Another ImportError: No module named qgis.core

Issue I feel like this is covered territory here, but the issue is has appeared on two separate occasions for me--first when upgrading from Ubuntu 12.04 to 14.04 in May. I got it fixed then, but I ...
0
votes
0answers
76 views

How to save a WMS layer at multiple resolutions as .tif using pyqgis

How can I export a wms-map-extent as a .tif from QGIS? Is it possible to call the "Save as.." function of a WMS-raster-layer from pyqgis? (E.g. by simulating right-clicking the layer, choosing "Save ...
0
votes
1answer
72 views

Cannot load postgis layer from sql string in pyqgis

I'm trying to load a layer using the following code in qgis python console: sql = "(select the_geom, ID from mytable)" uri = QgsDataSourceURI() ...
2
votes
1answer
33 views

How to store a password during one QGIS work session?

I'd like to get into qgis-plugin development, but am rather new to both python and QGIS development. I intend to write a plugin which connects data from a mysql database to shapefiles. As the data is ...
1
vote
1answer
107 views

How to delete selected features in Qgis using Python

I have a shape file with only one field DN. I would like to delete all features which does not have specific value of the field. Let say the DN can be 1,2 or 3. So far I was able to find out how to ...
0
votes
1answer
53 views

QGIS Python console - save image from bounding box

I want to save an image from QGIS but the save image functionality feels limited. My question is if it's possible to use the python command line to save an image at a specific zoomed in scale and to ...
1
vote
1answer
35 views

pyQGIS - Data Source is Invalid

Why I am getting Data Source is Invalid in python console of QGIS when running: vlayer = QgsVectorLayer("home/sanjayr/Desktop/india-latest.shp/buildings.shp","sanjay","ogr") I am using QGIS 2.4 on ...
1
vote
0answers
41 views

Clipping between features within a single vector?

Is it possible (via the Qgis API and friends), to clip polygonal features within a single vector layer? The hope is to accomplish this without having to duplicate the feature into a new layer. ...
3
votes
0answers
78 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 ...
1
vote
0answers
49 views

Using two different Python versions for QGIS scripting?

I´m intending to learn scripting with python in QGIS, but I have a couple of questions. I'm using Python 3.4 for learning which is installed in my laptop, but QGIS is using Python2.7 How could I ...
1
vote
1answer
121 views

Why is feature.geometry() None in my user-defined expression function?

I'm trying the user-defined expression functions for QGIS, as listed on Nathans blog: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ I always get the feature.geometry() as ...
2
votes
1answer
33 views

QGIS Processing - Additional Creation Parameter for GdalWarp

I am having a hard time getting the "Additional Creation Parameters" to work when using GdalWarp through the processing toolbox. I am trying to set the nodata value to 0 for the output raster. ...
2
votes
1answer
92 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
0answers
21 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 ...
5
votes
1answer
129 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
67 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 ...
1
vote
0answers
57 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 ...