Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
0answers
16 views

Unable to compile using make test(windows)

While trying to compile my test plugin I encounter this error. At the moment i can't figure out why it isn't working. I m using a windows and try to execute the command in OSGeo Shell. I typed in ...
5
votes
0answers
51 views

Sending a https request from a QGIS plugin using urllib2

I'm developing a QGIS plugin that needs to send https request to an API. I have to use urllib2 (see below if you want to know why I don't just use the requests package) The first request I need to ...
2
votes
0answers
44 views

PyQgis does not load a vector layer to form

I will want create "Hello World" project at PyQgis. I will want to show map on form.ui from .shp-file, but it does not download and show. But it is not loaded and does not appear. It`s value ...
2
votes
1answer
51 views

How to create a QgsFeature with default attributes?

I have a polygon layer loaded from POSTGIS database. This layer has a default value for the first column. I can create a new feature set that attribute to some predefined value with newFeature = ...
1
vote
0answers
30 views

QGIS Batch Processing error: AttributeError: 'NoneType' object has no attribute 'update'

I receive the following below error when trying to run Batch Processing in QGIS. I have tried uninstalling QGIS but still this problem persists. An error has occurred while executing Python code: ...
3
votes
1answer
76 views

get log of internal functions called by qgis

Is there a way to know which internal python functions are used by QGIS? e.g., when I click on "add vector layer" button I would like to know the functions that are called by QGIS. It would simplify ...
2
votes
1answer
28 views

Load postgis vectorlayer with AuthConfigId

I've tried to add a postgis-vector-layer in qgis 2.14.0 by using authentication (authConfigId) and PyQGIS. When running the script I'm asked to login by username/password instead of using ...
1
vote
1answer
49 views

How to filter out layers with QgsMapLayerComboBox?

I am using Qt Designer 4.8.5 to develop a plugin (with QGIS 2.14.3-Essen). I recently started to use QgsMapLayerComboBox widgets instead of the conventional Combo Box widget. However, I want to ...
3
votes
1answer
70 views

Add field and calculate expression with PyQGIS

I want to use PyQGIS to add a new field and calculate the values for each feature. Similar to Field Calculator option. My 'Field Calculator' expression is for example: y(start_point($geometry)) from ...
1
vote
1answer
54 views

How can I add output vector to a list to loop a geoprocessing on it?

I have about 18000 circular buffers that I want to transform in some kind of a wind rose. To do this, I transform the buffer polygons to lines, create points along the lines on the wind directions ...
1
vote
2answers
49 views

Rpy2: how do I use the function 'as' (r library methods) in python?

I want to coerce an object of class Raster Layer to class SpatialPixelsDataFrame since that is required as input for the function autoKrige from the r library automap. However, when I try to use as ...
1
vote
1answer
115 views

Regrouping points together qgis based on a sum

I work with QGIS and Python. I have a vector layer containing points. Each point has an attribute called 'number of houses' I want to dissolve this vector layer in many areas, each area must contain ...
2
votes
1answer
32 views

Get indices from pixels with a certain value in PyQGIS

I'm working in the Python-Console of QGIS and I have an object form the class QgsRasterLayer. I want to get the indices of those pixels that have certain pixel value (e.g. I need the indices of all ...
3
votes
1answer
43 views

Concerning “Error when using r.series in a python script”

Based on the "Error when using r.series in a python script" discussion (Error when using r.series in a python script) and based upon the solution given by Joseph I tried to make the same but by using ...
1
vote
1answer
52 views

PyQGIS Processing - wrong number of parameters

I'm facing a very strange issue from the module Processing using it as a standalone (not in the Qgis python console). I'm trying to create voronoi polygons from a points csv file. I can load my file ...
8
votes
2answers
177 views

How to set transparency to multiple raster values with Python

With the following code I can set 100% transparency to raster value 0: map=None for lyr in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr.name() == "some_layer": map= lyr tr=None ...
6
votes
0answers
78 views

Development of a plugin which depends on an external Python library

I'm developing a Python plugin, the target is integrating into QGIS the functionalities of a PyPI Python library called 'elevation'. Is there an OS independent way of installing external Python ...
4
votes
1answer
75 views

How to enable/disable snapping functionality with PyQGIS?

Goal: The snapping functionality should be enabled and disabled. I use the function setSnapSettingsForLayer. Convenience function to set snap settings per layer. Short Example: QgsProject.instance()....
3
votes
1answer
35 views

QgsDataSourceuRI and left outer join

I'm trying to load data from different tables using left outer joins into a QgsVectorLayer. The approach I'm following so far is the one from the developers cookbook here. The underlying database is ...
4
votes
1answer
62 views

How to use joinFieldNamesSubset from QgsVectorJoinInfo class

I have written a small python plugin to refresh a join on a point layer in QGIS. point_layer=None for lyr1 in QgsMapLayerRegistry.instance().mapLayers().values(): if lyr1.name() == "point_layer": ...
2
votes
0answers
24 views

qgis spatial index nearestNeighbour returns arbitrary number of elements

Why does QgsSpatialIndex.nearestNeighbour(Point, 1) returns more than 1 element some of the time? I specifically set it to return the closest one neighbour. What's the problem here?
4
votes
1answer
50 views

Register custom qgsfunction in pyqgis

I'm using pyqgis within an standalone application. Now I wanted to create a custom expression to to use as filterExpression in rule of ruleBasedRendererV2. (I tried the renderer with existing ...
0
votes
0answers
42 views

Merge neighbors together Qgis Python

I have one layer which contains lots of features (polygons), each feature represents a house and each house has an attribute called 'number-of-habitant'. What i want to do automatically with python is:...
2
votes
0answers
41 views

Set Snap Mode with PyQGIS

I am trying to set snap mode within QGIS plugin. So far, I have tried: QgsSnappingUtils().setSnapToMapMode(QgsSnappingUtils.SnapAdvanced) and QgsSnappingUtils().setSnapToMapMode(2) without ...
3
votes
0answers
32 views

PyQGIS select layer by original table name

As far as I see, on QgsMapLayerRegistry.instance() there is a method to select layers: mapLayersByName(Qstring) and the method mapLayer(QString) respectively, wich accesses a layer by its id. ...
1
vote
0answers
33 views

pyQGIS - hide loading gml dialog

Using pyQGIS, is there a way to hide the loading gml dialog when making WFS http requests via a plugin (for QGIS versions >2.4): After running this statement the load dialog shows: QgsVectorLayer(...
1
vote
0answers
38 views

QGis through python script : no map exported (map will be printed here)

I am very new to GIS in general and even more to QGis. I have a pretty simple task which is to import all shapefiles in one folder, style them and finally export them. I have wrote python code that ...
3
votes
1answer
46 views

QGIS QImage, can't specify a specific path

I'm a newbie in QGIS and I have to write a small python script to automate shapefile loading, applying style and save image. I'm having trouble on this last item. Here is the thing: img.save("...
1
vote
1answer
26 views

Faulty behavior after a cut operation

Short explanation of my problem: On the picture two polygons are shown. The highlighted (yellow) polygon is above the green polygon. Now, two operations are performed. yellowFeature.geometry()....
1
vote
1answer
28 views

How to load the only selected features from the layer in postgresql to Qgis canvas

I am using the uri to load the layer from the postgres to qgis canvas but it is not loading the selected features without where condition it is loading the lAYER. canvas = qgis.utils.iface....
2
votes
0answers
50 views

How to set “draw line inside polygon” using Python?

In the QGIS properties of a layer I want to activate "draw line only inside polygon" for a specific layer, but using Python. I don't want to use the GUI for it. Can this be done? I set the line ...
1
vote
2answers
102 views

Can't render my own map canvas

My goal is to make a standalone application using the QGIS library, but for now I'm trying to make everything work in a Qgis plugin. I need to create a map canvas inside my plugin window. There is ...
3
votes
2answers
52 views

How to optimize QgsFeatureRequest with filter expression

I have a point PostGIS layer (my_layer) which has more than 66000 features. I am getting the features I want but it takes too long. My code is: resultList = [] req = QgsFeatureRequest()....
1
vote
1answer
43 views

PYQGIS Layer to KML?

I am aware that it is possible, in QGIS, to save your Vector Layer as a KML file manually, however, I want to know if there is anyway I can do this programmatically from an external Python Script that ...
7
votes
3answers
201 views

Programmatically finding polygons which are >90% overlapped by another vector polygon layer using QGIS?

I'm trying to figure out how to use python to extract the polygons in one vector that are overlapped by >90% by another vector. I would then like to have a vector/map that will only show those ...
3
votes
0answers
58 views

QGIS canvas refresh & rendering control from plugin?

Plugin Description I have been working on a plugin which essentially doing the same as "GPS information" live tracking but with capability of displaying two GPS streams. I am comparing streams and ...
1
vote
1answer
23 views

How to integrate Live layer effect in QGIS 2.10 with the help of python code based automatation process?

I need to work with live layer effect (blur, outer glow, shadow) etc . I know how to use this with the help of QGIS symbol tool. But i need to integrate this in to my python automated map generation ...
6
votes
3answers
290 views

Is there a way of labeling the number of points with the same coordinates?

After reading through the following question (which is kinda related but not quite what I need): How can I show points on the same coordinate as e.g. a bigger symbol in QGIS? I found out that there ...
2
votes
1answer
85 views

How to refresh MapCanvas while PyQGIS-script is running?

I try to write a PyQGIS script similar to this: Use of python console to prepare offline map from WMS (tile downloader). Basically there are two loops to pan the mapCanvas, refresh the mapCanvas and ...
2
votes
2answers
80 views

How can I add a second Toolbar Button and Dialog to a QGIS plugin built with Plugin Builder?

I want to create a toolbar with 2 buttons, each button opening a different form. The steps I followed are: Created a plugin using Plugin builder Created a toolbar with 2 buttons by doing the ...
1
vote
0answers
25 views

How to add fields to postgis layer loaded in qgis using python

I have loaded a layer from Postgis in qgis and I am adding the fields to the layer using the follo code snippet: canvas = qgis.utils.iface.mapCanvas() aLayer = canvas.currentLayer() field_name = "...
2
votes
1answer
38 views

QGIS Python variable not updating after new features are inserted

I have the following script that sets the a feature id automatically after a new feature is digitized. I added the function inside the project's Macro section inside openProject() function: The ...
3
votes
1answer
33 views

QGIS python getting number of new features to be stored in layers

I mean, how could I get the number of features that have been created in a given layer and that are pending to be saved in the layer when "Toggle editing" or "Saving layer edits"?
2
votes
1answer
40 views

QGIS Error while executing Python function in openProject() Macro: “QgsMapLayerRegistry is not defined”

I have the following script that sets the a feature id automatically after a new feature is digitized. I want the following function to be executed automatically when project is opened (and layers ...
1
vote
1answer
38 views

QgsMapCanvas object is not callable (Ubuntu with, Eclipse, Python & QGIS 2.0)

I'm basically borrowing the code for picking up a coordinate from a mouse click from this answer : How to programatically check for a mouse click in QGIS However in a stand alone application I do ...
3
votes
2answers
146 views

Removing layers with zero features from QGIS

I have more than 100 layers loaded in map canvas. Some layers don't have any feature. I would like to delete all layer with zero feature count. Is it possible to get a script which can delete all ...
2
votes
1answer
34 views

Problem using processing.runandload(…)

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
48 views

How is it possible to programmatically export current view as georeferenced image with QGis?

I found the this to export the current view as image. The following code works and was accepted as answer. c = iface.activeComposers()[0].composition() image = c.printPageAsRaster(0) ...
1
vote
0answers
25 views

How to rollback the committed changes in the Vector Layer in qgis

I selected few features in the vector layer and updated the field. But I want to rollback the changes committed to the vector layer. How can I do that in QGIS? I have used used the following coed: ...
3
votes
0answers
61 views

How to integrate python-docx with QGIS

I have installed the newest QGIS and downloaded python-docx from this link python-docx . I haven't installed separately a different version of python. Is it possible to integrate this package of ...