Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
55 views

Error doing processing.runalg

I have been working in this code but I am getting the following error: Traceback (most recent call last): File "", line 1, in File "c:/users/miguel~1/appdata/local/temp/tmpdsyhqn.py", line 17, in ...
2
votes
0answers
29 views

Programatically populate field_4 after choosing values from other fields?

I'm working with QGis 2.8, editing the attribute table of a SHP file, named "myTable". I need to populate field_4 with the conditions listed below: For 1 to n (it runs across records of myTable) ...
2
votes
1answer
48 views

Module Map Composer not found

I am using Map Composition, but I found in QGIS 2.14 (Essen) Text Editor that when I try to import MapComposerit returns that this module is not found. This is the error : File "C:/PROGRA~1/...
2
votes
2answers
56 views

I don't get any output from Reprojection

I have recently posted a Reprojection issue. I found the solution, but now I can't get the output: I load the resulting reprojection by code, but first, I look into the folder where I have indicated ...
1
vote
1answer
19 views

Overriding method of qgis object does not work

I try to reimplement the renderDiagram() method from QgsHistogramDiagram to add some labels directly to the diagram (using the position argument). So far, I tried to set up my own class to override ...
2
votes
1answer
56 views

Algorithm fails (not found) : gdalogr:warpreproject

I am using the code in "QGIS Python Programming Cookbook", testing the code to learn about programming in QGIS. But when I try to reproject a raster, I get the error: Error: Wrong number of parameters....
2
votes
2answers
275 views

How to iterate over layers and export them as PNG images with PyQGIS in a standalone script

I would like to export specific layers as a png from a QGIS .qgs map. From the table of contents the script would first export the "boundary, climits, and Div1_Irrig_1956_0" layers as one png. The ...
2
votes
1answer
56 views

How to automatically reload a layer every 30 seconds?

I need to 'triggerRepaint()' a rasterLayer every 30 seconds, it's possible do it in QGIS? perhaps, a background process ui in python? create a watcher in python like QFileSystemWatcher
0
votes
0answers
12 views

Can't get new layer from QgsGeometryAnalyzer [duplicate]

I have this user's problem as well. When I click "RUN" in the Text Editor in QGIS, nothing appears, and I haven't got any errors. It is a very symbply class but surprisingly, I can't get any result. ...
1
vote
0answers
44 views

ogr2ogr - Shapefile database SQL query; missing .cpg and .xml

I am using gdal and ogr2ogr to perform a SQL query on a database of shapefiles with the code below. The geoprocessing works and the appropriate shapefile is extracted from the query, but when I print ...
2
votes
1answer
47 views

Displaying layer after using QgsGeometryAnalyser?

I have already discovered this class, but I am confused. If I am doing a analysis on the current layer, I don't know why it is not displaying on the map. lyr =iface.mapCanvas() layer = lyr....
2
votes
2answers
52 views

I am looking for a Python method to Split the list of attributes in a layer

I have a list of attributes in QGIS: [137.0, u'0101S', u'MUNICIPIO', u'28004', 19849.4753178, 22000935.5836, u'\Alamo, El'] And I am trying to obtain each element in the list, using pyqgis. I can'...
2
votes
2answers
46 views

using PyQGIS to subsample a region of a raster layer's pixel data

I am having trouble sampling multiple pixels from a raster layer at oe time. If I want to sample pixel data from a layer at a particular coordinate I can write. ident = layers[0].dataProvider()....
4
votes
1answer
43 views

PyQGIS toggle group visibility (and recursively subsub…group visibility)

I would like to set visibility of a layer group and all of its children (and grand-children and so on...) using PyQGIS (QGIS 2.14.1). Assume the groups name is g0 with subgroups g0[1...n] and subsub.....
3
votes
1answer
89 views

Retrieve pixel value from raster layer in pyQGIS

I am trying to access the pixel data in all bands from a raster layer in QGIS from the Python Console. I have looked at several online resources including http://docs.qgis.org/testing/en/docs/...
3
votes
1answer
143 views

How to change a project variable using Python?

I'd like to change the value of a user-defined project variable (can be manually edited in Project Settings | Variables) using the Python console. I tracked down the setVariable() function in the ...
0
votes
1answer
75 views

Plugin with QT Creator and Python [closed]

I would like to develop a selection-plugin in qgis. It doesnt run because there is a Problem with the python script. I can select the layer. However, I dont know how can i choose between "ZD", "RD"...
0
votes
1answer
20 views

Getting the DB name of the spatialite table loaded inside QGIS using PyQGIS

I have a table loaded in QGIS from spatialite DB. When i see the layer properties it is dbname='/home/farook/Spatialite/Cities.sqlite' table="cities" sql=. Now i want the dbname alone (i.e) the entire ...
1
vote
2answers
110 views

How to add dynamic text feedback for QGIS plugin?

I am building a plugin using Qt Designer which will initially allow users to select features for a chosen polygon layer and then when a feature is selected on the canvas, the area is printed out in ...
4
votes
1answer
56 views

Connecting to a spatialite DB, querying, writing the queried result to a spatialite table using PyQGIS

I am developing a plugin that connects to a spatialite DB , do some queries and outputs the results to a spatialite table. I had tried with the below code to connect to the DB and print the queried ...
2
votes
1answer
46 views

QGis QDir remove directory problem

I am currently developing a QGis plugin and I need to create and remove directories and I use PyQt. I don't know if my problem comes from PyQt or QGis. So my program creates folders, that works all ...
0
votes
0answers
41 views

Debugging QGIS plugins using Eclipse IDE in Ubuntu?

I am using QGIS 2.14.1 in Ubuntu 15.04. I am developing QGIS plugin using Eclipse 3.8 IDE installed. I would like to configure pyqgis and debug the code using eclipse. Is there any documentation for ...
2
votes
0answers
63 views

How to add plugin icon to status bar using PyQGIS?

I would like add my plugin icon to the status bar at the bottom of the screen. How would I do that? (QGIS API documentation on statusBar() seems to be leading to the QT docs and that site is down ...
10
votes
4answers
365 views

How to snap a road network to a hexagonal grid in QGIS?

I'm trying to use QGIS 2.14 to snap a road network to a hexagonal grid, but I'm getting strange artifacts. I've created a hex grid with MMQGIS, cells are approx 20 x 23 m. I've buffered the road ...
1
vote
1answer
26 views

QGIS GdalUtils runGdal function throws error for second argument

I am trying to use a script provided in the QGIS Python Cookbook by Joel Lawhead - its a simple script that georeferences images based on control points via the gdalwarp function. (p.124 in the book) ...
1
vote
1answer
74 views

Global name not defined, is this a syntax error?

I have been working with classes, and I have fixed several mistakes related to indentation, but in this case I have been checking all the possible errors. It might be a concept error. If someone can ...
1
vote
1answer
35 views

PyQGIS: How to find features <within> another feature

Using a spatial query in QGIS Desktop to select features of layer MTA_ACQ_TE_polygon that are within features of layer nts_snrc_50k works, but I am attempting to do this programatically in PyQGIS, ...
2
votes
1answer
75 views

PyQgis: During editing, add new feature attributes

Workflow: Start edit mode -> New feature is created -> On the console (pyqgis), new attributes are set -> Exit edit mode. Problem: The attributes are not saved. Only after completion of the editing, ...
1
vote
1answer
51 views

How to spatially join several attributes of one layer to a unique one on a second layer

My goal is to link all the attributes of an input layer (that has a UTM CRS projection matrix and point coordinates but no geometries) to the geometries of another layer based on the spatial analysis. ...
2
votes
1answer
43 views

Using zonal_stats with python in QGIS to calculate statistics for each image

I work with Python in QGIS, I want to calculate statistics for each image that I have with a specify shapefile and save result after, I tried to do like this: from rasterstats import zonal_stats ...
1
vote
0answers
65 views

Python QGIS reliable intersection/overlap check between points and lines

In my script I need to check, whether a point I created stored in a memory layer lies on a polyline, which is in another memory layer. I am certain, that the point does overlap/intersect the line, ...
4
votes
1answer
53 views

How to insert a variable into a tool script

I am a bit new when it comes to Python programming. I'm trying to run the GRASS r.sun plugin tool to calculate the global irradiance for my chosen area for the whole year. The problem is that r.sun ...
3
votes
1answer
86 views

PyQGIS Error: Cannot Create a QPixmap or Qwidget when no GUI is being used

I am trying to create a standalone script using the code below. I was able to add a shapefile with no errors but when I add map = QgsMapCanvas() after qgs.initQgis() and map.setLayerSet([...
1
vote
1answer
49 views

Connect / Disconnect GPS device via PyQGIS

In QGIS I would like to establish a connection to my GPS device programmatically (not via button in the GPS control panel) I found out how to get available ports with QgsGPSDetector i.e. ...
1
vote
1answer
55 views

Qgis -> Settings -> Customization : how to import ini file with python?

With QGIs, from "Settings"->"Customization" i can hide/show the components of the GUI. I can export a INI file with my customization. There is a way to import my INI file with a python command in ...
1
vote
1answer
78 views

QGIS - Clip: Differences between processing commands and built-in Python console

Two geometries can be clipped in various ways. I have expected the same result, but I got two different results. The following method I used. I have selected the clip function and added two layers. ...
1
vote
2answers
54 views

Create GeoJSON after processing.runalg('qgis:clip', …)

I have the following problem: I have two vector layers, foobar and clipLayer. About the python console I call the following command: processing.runalg ('qgis:clip', 'foobar', 'clipLayer', None) As a ...
2
votes
0answers
18 views

Plug-in reloader

There's something i don't understand in the behaviour of the "plugin reloader" plugin : When an error occur in the test of a plugin "plugin reloader" reloads a new instance of my plugin (the one with ...
2
votes
1answer
34 views

Raster brightness, contrast, saturation in PyQGIS

I'm trying to find a way to change these properties (especially contrast and brightnes) and I've found a QgsBrightnessContrastFilter class, but I can't fugure out how to apply it to my raster layer. ...
1
vote
0answers
47 views

How do I calculate the percentage of progress using raster data using Python?

How do I calculate the progress amount of two or more raster data being processed? I have seen examples of vector data but it becomes difficult to calculate the progress when no vector data are ...
2
votes
0answers
51 views

Fatal Error when PyQGIS searches for available providers: QgsApplication.initQgis()

I am setting the prefix path in Python using the code below. When running the code, a pop-up window stating "python.exe has stopped working" shows up. I've gone line by line in the code within ...
2
votes
1answer
132 views

PyQGIS Error using standalone script when loading a vector layer

I've been able to execute the command below in the Python console in QGIS. I am able to execute from qgis.core import * and import qgis.utils with no errors in the OSGeo4W shell but adding the layer I ...
3
votes
1answer
76 views

Error when using r.series in a python script

I’m writing a tool script in python and at a certain point I want to use the GRASS tool r.series. I want the algorithem to read all raster files from a folder and calculate the maximum with r.series. ...
3
votes
1answer
94 views

Show QGIS feature count via console on existing layers

I want to make a script that toggles feature count on for all vector layers. I followed the following article: Show feature count of layer via Python console / PyQGIS. Instead of adding new layers ...
2
votes
1answer
55 views

Categorized Renderer

I am trying to set a categorised renderer for a point layer, according to its categories. I used this code: vector = QgsVectorLayer("route to shape", "title", "ogr") mi_rend = ...
3
votes
2answers
166 views

How to add a shapefile programatically using PyQGIS

I am trying to add a Shapefile outside of the QGIS environment using PyQGIS. Ideally this would be done without creating a map in QGIS. I've started with the code below but am receiving the following ...
1
vote
0answers
25 views

pyqgis change or update attribute data with real-time data or Timer update,Memory has been growing

I update my shapefile attribute data by QTimer ,and labling it, keep the lable visiable,change attribute by 1 minute, but the Memory has been growing 1 layers =self.iface.legendInterface()....
1
vote
0answers
67 views

Writing custom GUI map application without installing QGIS

I would like to know if it is possible to develop standalone map applications with QGIS without installing QGIS software or embedding QGIS. Most instructions ask to either install QGIS or embed in to ...
2
votes
1answer
84 views

Delete all fields with the string “RAWI” using QGIS Python

I would like to delete all fields with the string "RAWI". For instance the field "RAWI_WA" and the field "RAWI_BO" should be deleted but not the field "NSG_RAW"
1
vote
2answers
153 views

Couldn't load QGIS utils; Python support disabled; No module named future

Unexpectedly Qgis won't open today. Error code is: Couldn't load QGIS utils. Python support will be disabled. Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.7/...