Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
80 views

How do I change the pixel values of raster data from QGIS python plugin

I have been trying my hand at a QGIS plugin. The plug in reads raster layer data into an array, pipes the data to a C++ program, does processing over there, and pipes my results back. After a couple ...
1
vote
0answers
39 views

How to incorporate QGIS custom widgets into plugin? [duplicate]

Developing a plugin with Qt Designer for QGIS 2.14.1-Essen on Windows 7 and having trouble inserting the QgsCollapsibleGroupBox widget. I receive the following error: ImportError: No module named ...
2
votes
2answers
51 views

QGIS Segmentation fault when manipulating QgsGeometry

So I am running QGIS 2.8.1 on Ubuntu 14.04. This following problem is happening in my script, but also occurs directly in the QGIS python console: lay = iface.activeLayer() lay.featureCount() 1L lay....
8
votes
1answer
221 views

Setting a default value in a QGIS field

I would like to add in a layer's field a default value. I mean, every time a new feature is created, that field would be automatically filled with the default value. In my case the default value ...
4
votes
1answer
82 views

Errror using the Simplipy QGIS plugin: 'QgsRasterLayer' object has no attribute 'selectedFeatureCount'

I am adding a raster in QGIS 2.14.1 and get this new error: AttributeError: 'QgsRasterLayer' object has no attribute 'selectedFeatureCount' I am not programming, just using a QGIS menu. I am using ...
1
vote
1answer
50 views

refresh programmatically created composer

I am trying to create a composer using pyqgis. Everything works as expected. The only difference compared to the manual creation of a composer is, that I am not able to update the layers (by pressing "...
0
votes
0answers
43 views

How to add dynamic text in standalone PyQGIS to reflect iteration of layer names

I am working with a standalone PyQGIS script below (that was given as an answer to How to iterate over layers and export them as PNG images with PyQGIS in a standalone script). The script exports the "...
3
votes
0answers
39 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
128 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: layer....
3
votes
0answers
63 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
64 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
29 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
26 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 qgis....
1
vote
0answers
25 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
42 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
90 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
96 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
74 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
60 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
16 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). Then,...
1
vote
1answer
115 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 sys.path.append("/Applications/QGIS.app/Contents/...
2
votes
2answers
40 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
68 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
65 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
99 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
67 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
44 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
22 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
56 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
228 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
56 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
57 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
66 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
317 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
59 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
53 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
48 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
55 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
49 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
48 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
109 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
155 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
95 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
22 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
120 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 ...