Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
0answers
48 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 ...
2
votes
0answers
49 views

Problem using processing.runandload() [on hold]

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") ...
1
vote
1answer
34 views

Label only selected features with PAL PyQgis using an expression

I'm trying to label only selected features with an expression using PyQgis and the PAL functions, but I don't find any example and the API don't help me a lot (or I don't found it). My Qgis version is ...
3
votes
0answers
30 views

The features don't appear at the first time in my exported PDF

my problem consists of exporting to PDF format. The first time I run my code (Text Editor of QGIS) the PDF only has the legend. But the second time, it has the features. Changing the line of ...
2
votes
0answers
30 views

Approach to controlling which layers display in a QgsComposerLegend

I've tried 2 approaches to control what shows up in print legends. Neither of them work which is troubling because other than pruning the layerRootTree in advance of composer.addItem(legend), there ...
1
vote
2answers
36 views

How to set the paper size to A4 for a PDF export with pyQGIS?

I have been developing this code, based on the official documentation of QGIS and some codes in gis.stackexchange. But my problem is that I don't know where to establish my height and width to make a ...
1
vote
1answer
64 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
0answers
21 views

addItem() method doesn't work [on hold]

I show you my code, but basically, I have been following the steps in the official bibliography about Map Composition The code works, but I don't get the items I have been adding to the map (scalebar, ...
4
votes
2answers
128 views
+100

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 ...
0
votes
2answers
43 views

How to connect push button in dock widget form?

Following this tutorial as a guide, I created a plugin using the Plugin Builder with the dock widget form. I am now trying to connect a pushButton to a function. The following is a snippet of code: ...
1
vote
0answers
18 views

I can't define “enum QgsComposerItem::ItemPositionMode ” to UpperRight

In order to create a new map layout with labels, I have to set in my code the position of the labels with ItemPositionMode, but it the parameter is not accepted: from qgis.core import * from ...
4
votes
2answers
808 views

How to get the file paths of the loaded layers in a QGIS plugin?

I am very new to GIS, QGIS and Python so please bear with me. I am using QGIS 2.0 and I would like to develop a QGIS plugin that would display the raster layers of the main window in order to allow ...
1
vote
0answers
15 views

QGIS cannot load macro function?

This has me stumped. For some reason, I can no longer run a function from a project macro even though macros are enabled (from Settings > Options > General > Enable macros > Always). Just ...
0
votes
0answers
29 views

How to georeference *.tiff to a given feature geometry automatically?

I´ve got the task to georeference an tiff image to the referencing polygon footprint (Polygon). I have found a lot of ways to do get the footprint from a raster but I could not find a way to use ...
4
votes
1answer
45 views

Can't delete features from layer using QGIS' Python API

I've only recently started using QGIS and it's Python API. Currently I've loaded two OpenStreetMap datasets. I would like to remove lines with from the second set where the name is already present in ...
4
votes
0answers
48 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 ...
2
votes
0answers
16 views

Create different print composers from different layers added to QGIS

I'm using QGIS 2.8.3 with windows 10. I want to know if it's possible and how to create, using python code, from each layer (in the table of content) a print composer to each one of them. Any ...
2
votes
1answer
320 views

How to deactivate my custom tool by pressing the Escape key using PyQGIS?

I'm developing a QGIS plugin and I have created a custom tool. Once the process is over, if the user presses the ESCAPE key, I want my custom tool not to trigger mouse events on the map anymore. How ...
0
votes
0answers
12 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
0answers
36 views

QgsMapCanvas not fully rendered and missing some layers in PyQGIS standalone script

I've been working with the script below with the help of @Germán Carrillo. The script renders all of the correct layers when showing the canvas window and exports the individual Div1_Irrig... layers ...
1
vote
1answer
47 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 ...
2
votes
2answers
27 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?
3
votes
2answers
43 views

Cannot load vectorlayer PyQgis

I am having a hard time loading a vectorlayer from the console. Not from the Pythonconsole within QGIS, but from the console on my computer. I later want to write a standalone script! That is what I ...
3
votes
0answers
156 views

How to change the group icon in legend via Python in QGIS 2.6?

How to change the group icon in legend via Python in QGIS 2.6? At version 1.x I did it this way: self.legendTree = self.iface.mainWindow().findChild(QDockWidget,"Legend").findChild(QTreeWidget) ...
4
votes
2answers
53 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: ...
1
vote
1answer
43 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 ...
4
votes
2answers
48 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 ...
4
votes
1answer
122 views

How can values in the attribute table be refreshed automatically when a geometry changes?

I can't find a solution for auto-refreshing attribute table data. For instance, how can the data related to features of a Shapefile (e.g., the area) be updated if the feature geometry is changed.
1
vote
0answers
27 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
17 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
24 views

How to programatically populate a 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
36 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
161 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
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
0answers
6 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 ...
0
votes
2answers
158 views

pyQGis scale based visibility problem

Im loading some layers from postgis using pyqgis in my standalone qgis app. For each layer i also load a style using: lyr.loadNamedStyle("style.qml") I've setup 2 versions of styles in qgis ...
2
votes
1answer
45 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 ...
9
votes
4answers
310 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 ...
3
votes
1answer
132 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
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
1answer
48 views

Create Plugin for Qgis 2.10 by using Eclipse

I finished to create my plugin and i compile it; I have : Myplugin.py, Myplugin_dialog.py, Myplugin_dialog_base.ui Is it in the Myplugin_dialog.py that i suppose to create new functions and add ...
2
votes
1answer
48 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
1
vote
0answers
32 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
44 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
46 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 ...
1
vote
1answer
43 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. ...
1
vote
1answer
62 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. ...
2
votes
1answer
29 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 = ...
0
votes
1answer
17 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 ...
3
votes
2answers
77 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 ...