Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
13 views

There is a Run Time error wile using the console.in QGIS

I was writing a post where I have pointed in my code which lines of code "make" QGIS to fail. But as the time as I was writing the post, I tested the code again in the Text Editor of QGIS (2.14). ...
1
vote
1answer
80 views

Writing result of PyQGIS to shapefile

I try to perform some zonal statistics on a shape- and rasterfile and write the output to a completely new shapefile! import sys # where is the module ...
2
votes
2answers
31 views

How to read the saved extent of the QgsProject?

I am trying to access the extent of QgsProject. How can i do that with PyQGIS?
2
votes
0answers
62 views

Problem using processing.runandload() [closed]

I'm writing a QGIS plugin using PyQGIS and I have a weird problem. When executing following line of code: processing.runandload("qgis:createpointsalonglines", r"Clipped", 1, 1, 0, r"memory:nodes") ...
4
votes
0answers
52 views

Issues updating field values programmatically for particular field data type on 64bit Windows computer using QGIS 2.8.7

I have an issue with a plugin for QGIS 2.8 I'm developing when using it on a Windows 64bit machine (as opposed to 32bit). I am trying to update values in a particular field in my plugin, and the ...
1
vote
1answer
54 views

Why does joining all layers in a group not work?

I am attempting to re-join all layers within a group to another layer ("Main.shp") outside of this group. The idea is for users to change values in one of the group's layers. As these layers are ...
4
votes
2answers
72 views

What's the correct syntax to use Processing gdalogr:merge from python?

I am using gdalogr:mergein Python console in order to merge to rasters (.tif) But I don't really understand the first parameter, where I have to put two variables. I get the following error: ...
4
votes
2answers
53 views

How to get layers in x number of subgroups?

I have a project which has dozens of groups and subgroups. E.g.: Main_Group > Sub_Group_1 > Sub_Group_1A > Layer_1A > Layer_2A How can I access ...
1
vote
0answers
35 views

Eclipse PyDev has quit recognizing QGIS objects

I followed the instructions for setting up Eclipse with PyDev to start creating QGIS plug ins found here: http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/ide_debugging.html after doing ...
0
votes
1answer
19 views

QGIS algorithm parameter: <ParameterString> [duplicate]

I have been working with the algorithm gdalogr:warpreprojectand have failed several times in the parameter in the title. Now, the problem is solved. It was about the EXTRA parameter. I read 3 books, ...
2
votes
0answers
51 views

Deployment of optical fiber QGIS Python

The subject that I’m working on is the deployment of optical fiber . I have a shapefile which represents a country containing homes. And I have another shapefile representing an infrastructure plan of ...
4
votes
2answers
186 views

How to render layer into png in a standalone application?

I would like to use standalone appliction to apply .qml style to a layer and use QgsMapRenderer() to save it as image on a hard disk. The are a lot of questions like mine at this site and it seems ...
1
vote
1answer
52 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
26 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
41 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 ...
2
votes
2answers
53 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 ...
0
votes
1answer
9 views

Override renderDiagram method from QgsHistogramDiagram

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
49 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 ...
2
votes
2answers
204 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
51 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
11 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
38 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
45 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 = ...
2
votes
2answers
48 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 ...
2
votes
1answer
31 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 = ...
4
votes
1answer
37 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 ...
3
votes
1answer
63 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 ...
1
vote
0answers
24 views

Atlas transparency in Pyqgis

I use atlas with PyQGIS. In my atlas i use a feature (atlas feature) with invert polygon, this feature have the transparency = 50%. When i generate atlas with composer no problem, but if I use the ...
3
votes
1answer
136 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
57 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", ...
0
votes
1answer
18 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
84 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
53 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
43 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
33 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
61 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
340 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
25 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
55 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
34 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
62 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
49 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
37 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
43 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
45 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
57 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 ...
1
vote
1answer
45 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
48 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
71 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
50 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 ...