Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
0answers
24 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 ...
1
vote
1answer
30 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,...
1
vote
1answer
44 views
+50

How to define border colour for rule-based style using PyQGIS?

I use the following to create a Rule-based style for a given layer which includes defining a label, expression and colour fill: from PyQt4.QtGui import QColor layer = qgis.utils.iface.activeLayer() ...
1
vote
1answer
23 views

How to load html file with leaflet map using PyQGIS

I have simple .html file with leaflet map layers. I want to load these layers in QGIS mapCanvas with ability to choose one of the layers. How can I load this .html and show one of map layer with using ...
1
vote
1answer
27 views

QGIS geoprocessing scripts, default values for field names

In QGIS geoprocessing scripts, default values must be provided for input numbers and strings, according to http://docs.qgis.org/2.8/en/docs/user_manual/processing/console.html#creating-scripts-and-...
3
votes
0answers
48 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
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 ...
6
votes
0answers
108 views

Using memory layer as input and/or output with runalg?

Can a memory layer be used as an input and/or output with runalg? With runandload I get this to work: processing.runandload("qgis:mergevectorlayers","memory:bufferOne", "memory:bufferTwo", r"memory:...
1
vote
0answers
9 views

How to write CRS info from QGSVectorLayer

I'm writing a plugin which will create a new virtual layer containing points. I know the CRS of the new layer, as it is the same as the layer I am using for input. I would like to specify the CRS in ...
2
votes
1answer
10 views

SyntaxError with custom function using QgsFeatureRequest.setFilterExpression

def get_subsel(layer,filter): layers = iface.mapCanvas().layers() for lyr in layers: if lyr.name() == layer: request = QgsFeatureRequest().setFilterExpression(filter) ...
0
votes
0answers
14 views

qgis python + layout/template + exporting in .png + filtering layers

Such a problem. I need to do a lot of pictures at different points from vector layer on each. And the picture (.jpg / .png) must be signed and so on - then the layout is best suited. Now I do a ...
0
votes
0answers
28 views

How to capture the event whenever the items inside the listview is enabled or disabled and get the number of enabled checkboxes inside the listview

I have a function "openBrowse" which will allow the user to select SQL files from a local path and display the file names as with dynamic checkboxes created based on the number of files selected ...
4
votes
4answers
6k views

How can I fix “ImportError: No module named qgis.core”?

First of all, I'm using Python 2.7.3, QGIS 1.8 (Lisboa) on Windows 7 pro 64 bits. Now let's go to the actual question: I have written some code (Python) that works well within the QGIS built in ...
2
votes
0answers
27 views

How can I change the origin (top left corner) coordinates of a raster using PyQGIS?

I am developing a python plugin for QGIS. The purpose of the plugin is to properly open an HDF5 dataset as a raster. Opening and displaying the raster can be done without the need for a plugin, ...
1
vote
0answers
21 views

Open raster and vector files with PyQGIS

I'm making a plugin for QGIS and I'm trying to open the layers I've created on QGIS, but I only get to open the one called 'sinkhole raster' which is the input of the tool. I don't know what order ...
2
votes
1answer
66 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
84 views
+50

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 Q3ButtonGroup). However, ...
2
votes
0answers
22 views

Importing submodule with python for QGIS?

So I am probably missing something really obvious here, but for some reason, I can't import submodules in my python plugin. This is the general structure of my plugin: ├── __init__.py ├── metadata....
1
vote
2answers
35 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 ...
5
votes
1answer
131 views

How to close/remove QGIS welcome page (recent projects) with Python?

Is it possible to close the QGIS welcome page with Python? I have a permanently docked Python plugin, that uses showRubberBand to directly write into map canvas. Therefor I have to close/remove the ...
2
votes
1answer
58 views

QGIS Filter layer by expression [on hold]

Can I make the filter by the value that is obtained by the function? for feature in iter: name_dot = feature['name'] print name_dot expr = QgsExpression("\"name\"=name_dot") selection= layer....
2
votes
1answer
31 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', "...
0
votes
0answers
19 views

Loading SpatiaLite tables with WHERE clause with pyqgis?

I have some layer in a SpatiaLite database that I want to filter and load in QGIS through pyqgis. From the pyqgis cookbook I read that it is possible to add a WHERE clause, so my script is like: db =...
1
vote
1answer
569 views

How to select and zoom in features from a QGIS Python Plugin

I'm very new to Python. I'm trying to find a way to select and zoom to the features from a QGIS layer. I've created a plugin and built a custom form. I have 3 values from the form which I need to ...
1
vote
1answer
41 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 ...
1
vote
1answer
15 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
38 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
20 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 ...
2
votes
1answer
53 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
28 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
37 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 =...
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
23 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 ...
3
votes
0answers
24 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 ...
3
votes
1answer
57 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 ...
5
votes
2answers
207 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 ...
4
votes
1answer
219 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
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 ...
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? [closed]

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
32 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
86 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
31 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
25 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....
1
vote
1answer
26 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
841 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
56 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?