Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
1answer
69 views

QGIS Symbol Categorisation

layer = iface.activeLayer() # get unique values for 'severity' field fni = layer.fieldNameIndex('severity') unique_vals = layer.dataProvider().uniqueValues(fni) # define categories to use in ...
0
votes
0answers
32 views

QGIS Custom Query Plugin

I am very new to QGIS plugin development. Is it possible to create a custom form (Field will be fixed and User can select only operator and enter value for field) to do custom attribute expression ...
1
vote
1answer
29 views

runalg('qgis:union', layer1,layer2,output) PYQgis

I need to use qgis:union in pyqgis algorithm and to merge 2 layers, layer1 and layer2 and "see" the output layer But i don´t understand how to work with the "output layer" this "output layer" have ...
1
vote
1answer
25 views

Print a centered map from a QGIS project for each point in a shapefile

I need to produce on the order of 100 maps that are centered on each point of interest in a shapefile. I would like to prepare all the layers in a master QGIS project, and set up the composition for ...
2
votes
1answer
42 views

if __name__==“main”: in standalone Python script for QGIS

I am working on a standalone Python script for loading shapefile layers into an application window with my central widget being canvas. The previous code I had written is almost identical to the code ...
1
vote
1answer
37 views

Running QGIS Python code from the R rPython package

The following script works fine from python or ipython at the command line: from qgis.core import * from qgis.gui import * import sys sys.path.append("/usr/share/qgis/python/plugins") from PyQt4....
2
votes
1answer
32 views

Adding a WMS layer in QGIS using python

I'm trying to write a python script to load the Environment Agency (EA) Flood Zones WMS layers into QGIS (2.14). I've provided a link to the EA's data catalogue at the bottom of this question. The ...
1
vote
0answers
26 views

Autofill fields of pyQgis script

I have three fields of output vector layer in Qgis script: ##output_vector_first=output vector ##output_vector_second=output vector ##output_vector_third=output vector When user fill first field I ...
3
votes
1answer
33 views

AddRaster using pyqgis

I am able to attach a raster by using python console using the command shown below. qgis.utils.iface.addRasterLayer('D:/Work/dt0017810q.tif') But, when the same image/raster path is read from a ...
1
vote
2answers
37 views

Access actions of ToolbarMenu/PanelMenu using PyQGIS

For a python plugin I need to remove/disable some UI elements so that they can't be accessed by the user. Thus, I removed the respective actions, toolbars and menus from the interface. However, in ...
1
vote
1answer
31 views

Algorithm not found

I'm trying to combine shapefiles in a folder of mine, but everytime i run it or run a variation of this it gives me the same error, "Error: Algorithm not found" this is my code: import os import ...
2
votes
1answer
68 views

QGIS Python Script - Python.exe Stopped Working

I purchased this book called Building Mapping Applications with QGIS and I am trying to work through one of the exercises. There is one script that I try to run that crashes python, generating the ...
2
votes
1answer
68 views

How can I trigger a QGIS plugin Event from map refresh?

I have a combobox in my plugin (python Qt dockable widget) that needs to contain the currently open rasters. How do I trigger an update of the plugin when something new gets added to the map?
2
votes
1answer
38 views

Add layers to Spatialite Database using PyQGIS

I would like to add layers into a spatialite database. I have used the QgsVectorFileWriter method: parcDisSHP='/xxx/xxx/xxx/xxx/FILE.shp' parcelasDis = QgsVectorLayer(parcDisSHP, 'Parcelas_Unicas', "...
2
votes
1answer
51 views

Plugin for fast export selected features from multiple layers

Is there any tool or plugin providing export of selected features from more than one layer on one click? I need to create multiple exports from three layers. Feature from layer one, then feature from ...
4
votes
1answer
112 views

How to load multiple vector layers into QGIS' map canvas using python scripting?

I am trying to write a standalone script in python to create a QGIS map canvas. The vector layers I am attempting to load are Shapefiles. Currently, I am able to load each vector layer, add them to ...
3
votes
1answer
35 views

QGIS geoprocessing script, ## hand-over processing-specific information error

I have a QGIS python geoprocessing script starting like this: ## Networking = group ## lIn = vector ## lOut = output vector from qgis.core import * v = processing.getObject(lIn) #[...the rest...] ...
2
votes
1answer
71 views

How to get attribute values from vector features visible in the qgis canvas

I have a vector layer (grid). Currently I select some tiles with the select tool and paste some python code to get information about these features. layer = qgis.utils.iface.activeLayer() ...
2
votes
0answers
42 views

problem using qgis spatial join in a python script or modeler : no results [closed]

I'm trying to create polygons from points layers. Each layer contains one point to avoid troubles due to superposition of polygons. I detailed the context here : How can I add output vector to a list ...
1
vote
0answers
57 views

Cannot run QGIS algorithm with python script without interface

I'm trying to run the QGIS 'intersection' algorithm from a Python script: (Working with Ubuntu) #!/usr/bin/env python # -*- coding: UTF-8 -*- import sys from qgis.core import * from PyQt4.QtGui ...
1
vote
0answers
23 views

Merging Shapefiles in a Folder using pyQGIS [duplicate]

I was reading the QGIS Python Programming Cookbook (page 74) trying to learn how to merge shape files because I need to do it for what I'm doing. I was using their example just to try it out though. ...
2
votes
1answer
50 views

How to include QgsRasterBandStats in plugin

I'm making a plugin were i want to get the min and max value of a raster. When i tried the following code in the qgis python console it worked fine but in my plugin code i get the following error ...
1
vote
1answer
49 views

Create Vector Grid from a features Extent with PyQGIS [duplicate]

NOTE: THIS IS FOR QGIS 2.14.1 and uses VectorGrid instead of CreateGrid also though the question How to generate a grid programmatically in Python without GUI? is answered fantastically the PyQGIS ...
2
votes
1answer
54 views

How to remove all layers from a group

I want to remove all layers from a distinct group. root = QgsProject.instance().layerTreeRoot() the_group = root.findGroup("my_group") parentGroup = the_group.parent() I think I have to loop the ...
2
votes
0answers
40 views

Making a pretty Base Map for QGIS and OpenLayers?

I am developing a standalone QGIS application as well a web GIS using Openalyers. Both applications use GeoServer published WMS and WFS services of parcels as a base layer. I was wondering if it is ...
2
votes
0answers
25 views

difference in behavior between merge from SAGA and merge from QGIS geoalgorithms

I'd like to know what I'm doing wrong with the merge algorithms in Python. I have several shapefiles (polygons) ending in 'LNA', 'LNC', 'LDA', and 'LDC', and I'd like to merge them depending on ...
2
votes
0answers
21 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
1answer
67 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
52 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
55 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
36 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
79 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
54 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
75 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
58 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
50 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
123 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
35 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
46 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
69 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
180 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 ...
7
votes
0answers
85 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
86 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
40 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
66 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
25 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
55 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
44 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 ...