Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
36 views

Add multiple rasters using QgsRasterLayer with for loop

I am trying to create a for loop for coloring up multiple rasters simultaneously. I am able to do it for one layer, but trying to implement the for loop to do it for more than one layer is proving ...
1
vote
0answers
11 views

Run processing (GRASS) algorithm as administrator

I am trying to use GRASS algorithms in a plugin of mine, in order to improve the quality of a shapefile containing lines that will be used as a graph later. The first algorithm I want to use is the ...
1
vote
0answers
7 views

Switch QGIS proxy settings programatically

I am using QGIS at two offices with different proxy-servers. At the moment I have to change the proxy settings manually every time i switch the office. I was wondering if its possible to change the ...
0
votes
0answers
6 views

Qgis Server error while loading wms layer in qgis

I have created qgis server by following link http://hub.qgis.org/projects/quantum-gis/wiki/QGIS_Server_Tutorial and http://docs.qgis.org/testing/en/docs/user_manual/working_with_ogc/...
11
votes
1answer
898 views

Releasing PyQGIS file locks?

I was wondering what triggers the release of file locks in pyQGIS? I am trying to delete a few data sources (used temporarily) by calling QgsVectorFileWriter.deleteShapeFile, but I have to quit QGIS ...
2
votes
3answers
80 views

No Module named qgis

I installed QGIS through OSGeo4W, and I am trying to write a standalone PyQGIS script, however, I am unable to import the qgis, qgis.core, processing ect… modules, as shown in the picture, I get the ‘...
2
votes
1answer
55 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
1answer
278 views

Can't get my QGIS external map to display on Ubuntu trusty: QObject::connect: Cannot connect (null) error

I've been following along the examples from the book "Building Mapping Applications with QGIS and for the life of me I can't figure out why my shape files aren't loading and displaying in the app ...
1
vote
0answers
25 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
37 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
54 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
42 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
35 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
49 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
89 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
11 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
14 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
29 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
32 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
23 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
94 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
24 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
133 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
61 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
32 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
571 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
50 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
16 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
21 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
54 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
58 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
209 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
221 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 ...