Tagged Questions

Python bindings for QGIS.

learn more… | top users | synonyms

0
votes
0answers
19 views

PyQGIS setSubsetOfFields function in QGIS 2.4

I found the function setSubsetOfFields to filter fields in a layer in the PyGIS cookbook: ...
1
vote
0answers
22 views

Apply graduated symbology renderer works in Python console but not in standalone script

I use the following PyQGIS script to load a vector layer from a shapefile and apply graduated symbology to it (tried to make it as minimalistic as possible). This works well in the QGIS 2.4 Chugiak ...
3
votes
3answers
39 views

Drawing some points in QGIS 2.4 using Python

I'm new to PyQGIS so here goes: Give a new QGIS project, how can we draw some Points on the map? I tried the following but nothing showed up. Should they be placed in a Vector layer before they can ...
0
votes
1answer
28 views

Programmatically Select a CRS in QGIS 2.4 using Python

When you run the following Python code in the Python Console of QGIS 2.4, uri = "file:///C:/data.csv?type=csv&xField=lng&yField=lat&spatialIndex=no&subsetIndex=no&watchFile=no" ...
2
votes
0answers
23 views

How to make added toolbar buttons exclusive?

I've added a toolbar to the QGIS mainWindow. Also I've added some checkable buttons to the toolbar. How can i now make my checkable buttons untoggle on QGIS default toolbars' checkable buttons press ...
1
vote
1answer
25 views

Use QGIS plugins in custom standalone application [duplicate]

I am trying to create a QGIS custom standalone application. I want to add the Google Physical map from OpenLayers plugin to my application when it starts, but I cannot seem to be able to access ...
1
vote
1answer
41 views

Show feature count of layer via Python console / PyQGIS

When working with vector layers in QGIS, I can display the feature count of a layer and, if applicable, the feature count per attribute category (e.g. when using categorized or graduated styling) via ...
0
votes
0answers
12 views

Filter MapComposer legend to only show layers visible on the map

I have written a function in Python / PyQGIS (no standalone application, so copy/paste it to the Python console editor to run it) that takes a VectorLayer as argument, creates a MapRenderer object for ...
1
vote
1answer
30 views

Use PyQGIS to import CSV and draw points using different color

A CSV file contains columns latitude, longitude and color. uri = "file:///C:/data/balls.csv?type=csv&xField=longitude&yField=latitude&spatialIndex=no&subsetIndex=no&watchFile=no" ...
1
vote
0answers
24 views

Highlight the selected feature with different colors

Is it possible to change the color of a selected feature in qgis 2.2.0 Valmiera? To highlight a feature I use: aLayer.Select(feat.id()) box = vlayer.boundingBoxOfSelected() ...
0
votes
0answers
34 views

Free ebooks of QGIS [duplicate]

I am new to QGIS and python. Can any one tell me, where I can find QGIS and Pyqgis ebooks for free.
1
vote
1answer
35 views

Calculating distance between latitude and longitude by using python

I have a database of 2000 points, which is in csv format of latitude and longitude. I want to find distance between these points all at once. And also showing these points in Map by using only pyQGIS. ...
1
vote
1answer
34 views

How to load a *.qgs file in a C++ QGIS standalone app?

I'm using QGIS-2.4.0 API to develop a standalone app by C++. I saved a test.qgs file in QGIS Desktop software, in the project, there was one layer and it was visible. Then I loaded the test.qgs ...
0
votes
2answers
24 views

QGIS 2.4 crashes when symbolizing QgsComposerShape in Python with ScriptRunner

I'm attempting to use ScriptRunner to output a jpeg of a red rectangle using QGIS Composer to understand the QgsComposerShape. Everything works except QGIS crashes when the symbol is applied. The ...
0
votes
0answers
15 views

Restart plugin from PyQGIS

I'm writing a plugin for QGIS and inside the method def run(self), after the OK button of the plugin is clicked, i.e., inside # Run the dialog event loop result = self.dlg.exec_() # See if OK was ...
2
votes
0answers
46 views

Iterating between two layers using QGIS python

I will try and explain my situation as clearly as possible. I just created my first plugin that is being used to analyze between various layers and give back quantities to the user. Most of it is ...
1
vote
0answers
26 views

Error Loading Layer/Shapefile in a Standalone Python QGis Application

I tried loading a shapefile on Python using PyQgis API but to no avail. I double-checked the path to shapefile and found it to be correct. QGIS module also seems to be imported just fine. When I ...
1
vote
1answer
34 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
37 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
25 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
39 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
79 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
40 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
33 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
26 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, ...
1
vote
0answers
22 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
31 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
15 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
56 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
45 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
42 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
30 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
60 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
27 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
29 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
33 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
57 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
39 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
38 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
76 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
60 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
48 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
20 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
86 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
53 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
42 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 = ...