Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
1answer
97 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
0answers
53 views

gdal_translate from within pyqgis [duplicate]

I want to use gdal_translate from within a python script in my plugin qgis2leaf. I've tried with ...
2
votes
2answers
78 views

How to switch to edit mode vector layers, in pyqt application based on qgis?

I do QGIS based application, I need to implement the ability to modify the geometry of vector layers in manual mode (editing nodes), how to do it?
8
votes
1answer
139 views

QGIS - Calling interpolation extension from python console

I would like to call the QGIS interpolation extension function (TIN method) (Raster->Interpolate) from python console. I can't find the corresponding function within QGIS API or within the ...
0
votes
1answer
100 views

How to open, modify and save a QGIS project with PYQGIS

I need to create a stand-alone script for opening a QGIS template project, modify a layer data source, export the Composition and finally save the modified .qgs project into a new file. So far I have ...
1
vote
1answer
68 views

How to programmatically export a composition as image?

QGIS Print Composer has tool "Save As Image" and I found appropriate function in QGIS source code exportCompositionAsImage. Is it possible to get access to existing Print Composer from Python console ...
0
votes
0answers
40 views

Couldn't load PyQGIS in QGIS 2.2 on Ubuntu 14.04 [duplicate]

This issue appears to be occurring with some frequency to folks in some shape or form. I upgraded from ubuntu 12.04 to 14.04, with loss of python functionality. My QGIS version is 2.2 from the ...
0
votes
1answer
35 views

QGIS API documentation in French?

I am looking for a document which explains what the API of QGIS is, with examples of this API but in French.
0
votes
0answers
28 views

Is it possible to customize openFeatureForm of pyqgis?

I am a beginner in PyQgis. I am trying create a plugin, which will be used to AddFeatue,Delete Feature, and Edit the Feature. It is more customized than which is provided by Qgis (2.2). I am capturing ...
1
vote
2answers
69 views

How to get features based on their attributes using Python - special characters?

I want to get features based on their attributes and it works fine when I use this Python script: canvas = iface.mapCanvas() curLayer = canvas.currentLayer() it = ...
2
votes
1answer
107 views

How to find the id of the last added feature using pyQGIS?

Is it possible to programmatically (in python) access the attribute info of the last added feature in QGIS 2.0 before edits are saved? I'm failing to find a way to get the ID and subsequently other ...
0
votes
0answers
10 views

search for examples of plugin of Multiple buffers [duplicate]

I am loooking for examples of plugin for Multiple buffers to help me to create a new one .
1
vote
0answers
122 views

Using qgis modules in standalone application with PySide?

I want to make small standalone application using PySide and QGIS python modules to display satellite images and do standard GIS operations, like creating new shape file and placing polygons or points ...
2
votes
1answer
53 views

How to add an interpolation raster from the python console in QGIS?

I'm trying to add an interpolation layer based on an existing vector layer by using the Python Console (initially in the menu Raster/Interpolation), but can't find anything related in the ...
0
votes
2answers
135 views

How to make a routable graph from a Point and a Line shapefile, using Networkx?

I have one shapefile which consists of all the streets in the study area, and another shapefile which has points representing origins and destinations. I would like to know if it's possible to find ...
1
vote
1answer
164 views

How to make a Python script that does a task in QGIS?

When I run this code in QGIS Python console it works fine, but I want want to run it from an external Python script. What I want the script to do is: 1- Open QGIS 2- Run this code 3- Close QGIS from ...
0
votes
0answers
47 views

PyQGIS: Programmatically Adding Point Features via QgsMapToolEmitPoint

I've created a map tool for QGIS 2.0 Python plugin that emits a point with the click of the mouse. I'm trying to create an edit tool, adding a point feature at the emitted point while selecting ...
0
votes
0answers
21 views

Qgis; How can I add only mean values instead of coun, sum and mean from QgsZonalStatistics (zonal statistic)?

I am using Qgis 2.2.0 Valmiers. I have ASCII grid, total 864 and I have a polygon layer as a zone. after zonal static batch run, attribute fields stop at 2046, fields number shown from "Table Manage" ...
0
votes
1answer
56 views

How to integrate pascal code into a QGIS model or plugin?

I have a console program that is written in pascal (lazarus) that reads in some raster files and parameter values as input. The code use dynamic 2D arrays to represent the rasters. I would like to ...
0
votes
1answer
39 views

How to select a specific area (in a polygon form) determined by some value range in a raster band?

For example, I want create a vector layer with polygons that represents all areas where the elevation is between 500 and 600. Someone has any idea to help me? I'm using PyQgis 2.2.
0
votes
1answer
48 views

PyQGIS: How to send signal to call unsetMapTool()

I've created a map tool to add some functionality to adding point features in QGIS 2.0. I'd like to unset this map tool if editing has manually been terminated by user. I've attempted as shown below, ...
0
votes
0answers
51 views

PyQGIS: QgsMapTool to add point feature

I am having issues programmatically adding point features using QGIS 2.0. I am trying to add a point feature, select another layer's nearby feature, and open the feature form to enter attribute data ...
1
vote
1answer
81 views

QGIS GUI Python Editor Code Running Exception

import sys from PyQt4 import QtGui class MessageBox(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.setGeometry(300, 300, 250, 150) ...
1
vote
1answer
106 views

Iterating over selected features in QGIS Processing

I used to be able to iterate over selected features using the following script in v2.0. import processing features = processing.getfeatures(layer) for feature in features: #Do whatever you need ...
0
votes
1answer
74 views

Programmatically set layer properties Python Init function

Is it possible to set the layer properties Python Init function field programmatically? I've been looking through the qgis 2.2 api but can't seem to find anything on it. Hint, suggestions and ...
0
votes
1answer
69 views

Developing QGIS plugin on Mac - GDAL

I'm developing a plugin for QGIS called DEMtools. It runs fine on my linux machine, but is causing me headaches when run on Mac OS X Mavericks (surprise, surprise). I keep getting segmentation faults ...
0
votes
0answers
45 views

QGIS Python API: SAGA difference algorithm does not split parts

I am using the QGIS Python API in an external script (platform: ubuntu). Everything works as expected. But when I am using the SAGA difference algorithm within the script, there is an issue. The ...
1
vote
1answer
69 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
0
votes
0answers
20 views

'QgsGraph' object does not support indexing

Traceback (most recent call last): File "/home/kasun/.qgis2/python/plugins/floogin/floogin.py", line 246, in findRoutes path=self.astar.astarSearch(graph, start, end) File ...
2
votes
1answer
68 views

Referencing Qt UIs external to plugin with python

I'm developing a plugin that sets up a working environment for a user: loading layers (from db), applying styles and several custom designed (Qt) UI files etc. Primary user interaction is in the ...
0
votes
1answer
38 views

Errors uploading plugin to QGIS python plugin repository

I'm trying to upload my first plugin to: http://plugins.qgis.org/plugins/add/ I keep getting the following error: There were errors reading plugin package (please check also your plugin's ...
0
votes
0answers
40 views

Running algorithm from Processing takes much much longer time than doing it from Qgis GUI

I have a road layer with 32000 features, and I want to find all the intersections. when I use processing->SAGA -> convert polygon/line vertices to points, it is all done in less than 5 seconds. ...
1
vote
1answer
96 views

How to get the map canvas CRS in EPSG code?

This is probably a simple request but I cannot find a way around it: how can I read from python the map canvas CRS? I know how to set it up: canvas = self.iface.mapCanvas() ...
1
vote
1answer
59 views

How to open most recent directory using PyQGIS?

For example, when I add a vector layer, next time that I want to add another layer it opens up where I chose my last layer from. How would one implement this in Python and/or PyQgis? I'm writing a ...
0
votes
0answers
29 views

How can I use the QGIS api on Jenkins

I have a python script with another script for unit testing. I would like to add it to jenkins to get continuous integration. Since I can't pip install qgis, how am I supposed to get the qgis api ...
0
votes
0answers
41 views

Determine Transect line to cover area

I'm near certain this is a solved problem, but I haven't been able to find a solution from searches so here's my situation (probably I'm searching the wrong thing)... I need to compute the ...
0
votes
0answers
27 views

Using QgsSpatialIndex for spatial join

I've written a bit of code to do a simple spatial join in QGIS 2 and 2.2 (points that lie within a buffer to take attribute of the buffer). However, I'd like to employ a QgsSpatialIndex in order to ...
1
vote
0answers
104 views

QVariant is not defined when using addAttributes

When I try to add a field programmatically with the following code: import os.path from PyQt4 import QtGui, QtCore legend = qgis.utils.iface.legendInterface() allLayers = legend.layers() for i in ...
0
votes
0answers
17 views

Is it possible to override default QGIS error messages?

From my QGIS plugin I would like to override/replace one of the the default QGIS error message ("The layer layer_url is not a valid layer and can not be added to the map") with my own message. I have ...
0
votes
0answers
60 views

Accessing CRS info with pyqgis in a standalone application

I'm currently having trouble accessing and defining CRS information in a standalone application. I've read the API documentation and have tried it in the python console in QGIS 2.2.0. The python ...
0
votes
0answers
66 views

How to pass a layer to a thread in PyQGIS?

In my plugin, a user can select one of the loaded layers from a combobox, and then proceed to do further calculations. These calculations are done in a separate thread, "WorkerThread". My question is ...
0
votes
0answers
27 views

Call post-execution command manually in QGIS Processing

I wrote myself a Processing Script and it works fine. Now i want to style the outcome (a new raster layer) with a QgsColorRampShader(), but the problem is that Processing adds the output after the ...
3
votes
1answer
245 views

“Couldn't load PyQGIS” Error running QGIS on Ubuntu 14.04

I have installed QGis on Ubuntu 14.04 from the QGis stable repository; it went fine with no errors reported. But when I launch QGis I get this huge window with the following message: Couldn't load ...
1
vote
0answers
42 views

QGIS python plugin: PyQGIS for spatial join

For a QGIS 2.0 and 2.2 Python plugin, I am trying to update one layer's field attribute with another layer's field attribute based on geometry function QgsGeometry.within(). My first layer is a point ...
1
vote
1answer
141 views

models from QGIS 2.0.2 to Python scripts?

I want to automate some tools for QGIS 2.0.2 using Python. Previously I have used ArcMap for automating tools and now i want to use QGIS. In ArcMap I used the ModelBuilder, and more specifically the ...
1
vote
0answers
90 views

PyQGIS: How to color raster layer with existing colorBrewerMap

With pyqgis I have added multiple new raster layers to the legendinterface(). Because i like the ColorBrewer style i want to color some of them with the "Spectral" gradient. How can I do this in ...
2
votes
1answer
78 views

PyQGIS: How to send signal if layer is currently in edit mode

I'm looking for a way to send a signal if a layer is in editing mode. I tried editingStarted(), but it wasn't working. I'd like to do something along the lines of the what I have below, but can't find ...
2
votes
1answer
62 views

Finding Code in QGIS Select Features Toolset

Can anyone tell me in what directory the pre-installed Python scripts for the QGIS selection tools (i.e., Select by Point, Select by Polygon) are found? I am using on a Windows 7 installation of QGIS ...
2
votes
1answer
84 views

How to implement 1:n joins with string attribute concatenation?

I have a question concerning pyQGIS. I'm a QGIS long-time (self-learned) user, but just a pyQGIS newbie. I want to implement 1:n spatial join with attribute concatenation in the table. I have a vector ...
2
votes
0answers
76 views

order layer in QGIS with pyqgis

I´m new in pyqgis. I´m looking for a code to move one layer in TOC to a specific position. Is it possible? Thanks a lot!