Python bindings for QGIS.

learn more… | top users | synonyms

0
votes
0answers
3 views

pyQgis reload a QGis plguin

I have a plugin that has a psycopg2 connection to a PostGis database. When i close GUI with the X-Button and open it again, all the widgets are filled with the data from before. It looks like the X is ...
2
votes
2answers
29 views

Setting layer visibility in QGIS Python API

Im having a problem toggling the visibility of map layers in pyqgis (2.4). I have a simple interface, just the map canvas, no legend, and basically a radio button that toggles between two raster ...
0
votes
1answer
19 views

osm2pgsql doesn't run in a QGis plugin

I have a problem with osm2pgsql when it runs in a qgis plugin. The function i use looks like this: osm2pgsql = "osm2pgsql -s -d {databaseName} -U {databaseUser} -H {databaseHost} -E ...
0
votes
1answer
27 views

How to run and debug PyQGIS scripts in PyCharm Community Edition 3.4.1

I am working with creating plugins for QGIS 2.4.0 (Chugiak). I am curious to know how I can write the codes, and debug them in the environment I am comfortable in, i.e. PyCharm Community Edition ...
4
votes
1answer
59 views

Why are my calls to SAGA routines in QGIS not working cross platform?

The ability to write and run cross platform scripts for QGIS using python is OUTSTANDING! However, when I try to run the SAGA:MERGESHAPESLAYERS algorithm from a python script it works fine in windows ...
2
votes
1answer
31 views

Create a new layer in PyQGIS with the same attributes of another preexisting and copy some elements in it

I'm new in QGIS and I'm trying to create my first plugin. I have a layer containing lots of elements of type Point, Line and Polygon. Suppose I want to create two new layers with the polygons above ...
1
vote
1answer
25 views

Get a list of layer names using PyQGIS

I need a list containing the names of all the layers in a QGIS session. I did the task as layersNames = [] for i in self.iface.mapCanvas().layers(): layersNames.append(str(i.name())) but this ...
2
votes
0answers
23 views

Assigning Color Ramp using PyQGIS

According to the PyQGIS Cookbook, a color ramp can be assigned in the following way: rlayer.setColorShadingAlgorithm(QgsRasterLayer.ColorRampShader) lst = [ QgsColorRampShader.ColorRampItem(0, ...
0
votes
0answers
18 views

Arcpy and pyqgis on same IDE

I have question: is it possible to set up arcpy and pyqgis on the same IDE (I use Pycharm). I have some problem with running my pyqgis scripts from pycharm. When I first configure Pycharm to recognize ...
1
vote
1answer
30 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 ...
0
votes
1answer
12 views

When does iface.mapCanvas().layers() get updated to the contents of QgsMapLayerRegistry.instance().mapLayers()?

Since the topic might be a bit cryptic, I'll try to explain where my problem is. I am currently developing a Qgis-plugin, where I am creating and adding some layers automatically, which I would like ...
1
vote
1answer
45 views

How to create a Processing script using the shortest path algorithm?

I'm currently using the Road Graph plugin to find the shortest path in a road network - however, I'd like to put this to a processing script (to be used in a model later) and the Road Graph Plugin has ...
2
votes
0answers
43 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
31 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
27 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
45 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
20 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
87 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
27 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
30 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
44 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
33 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
56 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
35 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
37 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
72 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
31 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
57 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
40 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
18 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
81 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
50 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
40 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
60 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
32 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
23 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
31 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
30 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
20 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
27 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
19 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
43 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
49 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
38 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
57 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
143 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
53 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
63 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
30 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
55 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 ...