Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
12 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 ...
1
vote
1answer
17 views

How to connect QtDesigner with python console on QGIS

I've created a script with python console on QGIS and an interface for my plugin with Qt Designer with QGIS 2.14.0 custom widgets. I would like to connect my sript with the interface but I can't find ...
2
votes
0answers
10 views

Finding vectors with wrong direction in river network

I have a shapefile containing network of rivers for the whole country. The description of the layer is saying that orientation of the vector should be the same as the river flow. This is true for most ...
0
votes
0answers
6 views

Dynamically move map canvas and main window using PyQGIS

I am trying to create plugin that will open new window with some layer, Dynamically "pan" my window, when main window is pan. So boundingbox coordinates should be the same in both windows. I need new ...
2
votes
1answer
24 views

Python to create new fields in many layers / QGIS

I have a number of line layers on which I need to perform the same task: add 4 columns with the start and end points of each line. The expressions that I use to do this are: $xat(0) $xat(-1) $yat(0) ...
2
votes
1answer
18 views

Trouble using “Clip Raster by Mask Layer” algorithm QGIS

I'm having issues using the "Clip Raster by Mask Layer" algorithm to clip a raster by a shapefile. When I run the algorithm, I get an error saying that the mask layer could not be loaded, even though ...
2
votes
1answer
27 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 ...
3
votes
1answer
30 views

Unable to create field for PostGIS layer. PYQGIS

I'm having some troubles to create a new field in a postgis layer.This is the code I'm trying to use, but nothing happens, no field is created: from PyQt4.QtCore import * dbnam = "pruebapython" uri =...
1
vote
0answers
12 views

How to implement a Plotting widget into already existing PyQt4 Interface

I am using Python, PyQgis for about one week and already built a plugin for GIS 2.14 which is -so far- working pretty well. As my next step I want to add a widget to plot data to my already existing ...
3
votes
2answers
2k views

How to generate a grid programmatically in Python without GUI?

Is there a QGIS Python binding for generating a grid programmatically without using the GUI?
0
votes
1answer
19 views

Invoking QGIS style dialog from Python standalone script

I can load a layer, open a canvas, and draw the layer in the canvas using the Qgis python API. Can I bring up the properties dialog, or even just the "Style" tab of the properties dialog, from such a ...
1
vote
0answers
21 views

QGIS: startup.py executed twice?

To test something I have a very simple startup.py file in my .qgis/python folder: import qgis qgis.utils.iface.actionShowPythonDialog().trigger() print "Welcome chump" Python console launches fine,...
2
votes
0answers
12 views

Zonal Statistics calculator differences between QGIS Lyon and Wien

I am trying to implement a process that uses the Zonal Statistics menu function. In Lyon, the menu that pops up had a field with a list of calculations, each with a check box. Here you can select what ...
0
votes
0answers
22 views

How to use Qt3 Support widgets in QGIS plugin?

Similar to this post: My plugins crashes with “No module named qgsprojectionselectionwidget” in Windows. Except I would like to also use Qt3 Support widgets (in particular, a Q3GroupBox). However, ...
2
votes
1answer
49 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 ...
1
vote
1answer
23 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', "...
5
votes
2answers
206 views

Field Editor with Python: select by attribute & open table (QGIS)

I want to search on number values (>, = etc.) within a column and open table for the selected ones. It's an easy task within field calculator, but I want to see how it's build up with the python ...
1
vote
1answer
27 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 ...
3
votes
1answer
197 views

Adding QGIS-specific Python interpreter to Eclipse?

I was following the steps from QGIS Python Programming CookBook to add qgis interpreter to eclipse, however I went into the following error in step 8: "See error log for details. No output was in the ...
0
votes
0answers
31 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 ...
3
votes
1answer
345 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
1
vote
0answers
60 views

Rendering shapefiles (.shp) to TIF with labels? [on hold]

I've basically copied the script below with minor tweaks from a few other posts here on stackexchange. When I run my code and all I get for output is a TIF that's white with a legend. For the life of ...
2
votes
1answer
29 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 ...
4
votes
1answer
81 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
25 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
1answer
22 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....
0
votes
1answer
21 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
25 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 ...
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 ...
2
votes
1answer
826 views

How I can get coordinates by clicking on the QGis Canvas with PyQGIS?

Are there any procedures when working with QgsMapCanvas (pyqgis, qgis) in order to obtain a pair of coordinates by clicking on the map canvas? Are there any sample Python codes that demonstrate this?
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 ...
2
votes
1answer
49 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
0answers
37 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
2answers
62 views

QGIS explode lines from python script fails at alg.processAlgorithm

I've been trying to run QGIS procedures from python scripts via terminal on Ubuntu (ultimately I want to automate a process via cron). The first task I have tried to script is the "explode lines" ...
2
votes
1answer
42 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 ...
1
vote
1answer
111 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 ...
1
vote
2answers
91 views

Adding a csv layer in PyQGIS

I am trying to load a series of csv files as vectors in PyQGIS. I run this code to try to get the first one: uri='file://D:/Saved Stuff/gulags/1.40.csv?delimiter=;&yField=y&xField=x' layer = ...
2
votes
0answers
40 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 ...
0
votes
1answer
203 views

How to connect mouseclick to map canvas in QGIS?

How to connect mouse click to map canvas in QGIS using python script? I have two lines of code to connect mouse click to map canvas: button.clicked.connect(self.onClicked) self.areapushbutton.clicked....
2
votes
0answers
37 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 ...
3
votes
1answer
32 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
129 views

PyQGIS Error using standalone script when loading a vector layer

I've been able to execute the command below in the Python console in QGIS. I am able to execute from qgis.core import * and import qgis.utils with no errors in the OSGeo4W shell but adding the layer I ...
2
votes
1answer
63 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() ...
-3
votes
0answers
17 views

I am trying to delineate watershed. But anytime I create watersheds, I keep getting this error message [closed]

An error has occured while executing Python code: Traceback (most recent call last): File "C:/Users/wisdom/.qgis2/python/plugins\QSwat\delineation.py", line 414, in runTauDEM2 self.runTauDEM(...
1
vote
0answers
52 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
20 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
2answers
489 views

How can i use python QGis network analysis library to calculate short path based on speed and distance?

I want to calculate and show short path from starting point to an end point in a qgis python plugin. in my research i stopped by an article about QGis network analysis library; http://www.qgis.org/en/...
2
votes
1answer
24 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
33 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 ...
8
votes
2answers
176 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 ...