Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
0answers
36 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 ...
4
votes
1answer
91 views

Bold and Italic layer labels with Python in QGIS

I'm trying to apply some labeling properties to a layer using Python. Everything went fine, except the way I tried to apply the Bold and Italic settings. Here is a part of the code: ...
3
votes
0answers
54 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
41 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 ...
2
votes
0answers
25 views

addItem() method doesn't work [closed]

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, ...
1
vote
0answers
20 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 ...
1
vote
0answers
22 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
35 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
63 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 ...
2
votes
1answer
66 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 ...
0
votes
2answers
55 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
1answer
38 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 ...
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
82 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
34 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
63 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
54 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
56 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
54 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
188 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
53 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
27 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
54 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
12 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
50 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
221 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
54 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
40 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
46 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
49 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
2answers
42 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
38 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
69 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 ...
3
votes
1answer
137 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
60 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
85 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
54 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
34 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
62 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
345 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
57 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 ...