Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
18 views

PyQGIS refresh layer tree programmatically

When programmatically applying a subset string to a vector layer (here: ax_flurstueck with object count 34265) via l = iface.activeLayer() l.setSubsetString('gemarkungsnummer in ('2760','2765','...
0
votes
0answers
4 views

Dynamically load symbols preview to plugin

I am working on plugin which combines two *.qml files into new one. Now I'm trying to generate something like "list" in plugin interface. What I have done so far is saving repeated in both files keys ...
0
votes
0answers
3 views

import error of qgis.core even though PYTHONPATH set up with system environment variable

I made the environment variables as described here: How2 Import Though I still receive this error: C:\>python Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32 ...
0
votes
0answers
19 views

QGIS 2.14.4 How to get the legend of a Vector heatmap layer?

I'm new on QGIS and PyQGIS. I'm trying to create a plugin which aims to apply a style on a vector layer (generated from a csv file) and then save the map as a png file. The style I apply on the ...
3
votes
1answer
353 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
16 views

PyQGIS QgsVectorLayer.uniqueValues() override active object filtering

This code snippet gives me the unique values for a vector layers attribute called myfieldname l = iface.activeLayer() attrIndex = l.fieldNameIndex('myfieldname') uniValues = l.uniqueValues(attrIndex) ...
2
votes
1answer
47 views

QGIS Calculate Field with Function Editor invalid expression

I have some data which is built like this: a,bbb,ccc where bbb and ccc vary in length. I want to extract the last segment of the string, after the second ",". Using the Function Editor: from qgis....
0
votes
0answers
14 views

laszip batch process in qgis extension lastool

i am using qgis 2.16 in that lastool plugin contains laszip option. please tell how to run batch process in laszip. ill not able to add multiple files at a time in batch process.result came only for ...
3
votes
1answer
46 views

Why do I get “Data source is invalid” error when calling method?

QGIS 2.14 on Windows 7. I'm trying to call a method in a python script from the QGIS python console. I've put the directory in which the scripts resides in the PYTHONPATH in both the windows system ...
2
votes
1answer
27 views

QGIS 2.14.4 attribute table fields not visible in Statist plugin

I had one point shapefile to which I joined new numerical attributes by a csv text file. I saved it by right clicking and everything works fine, I use it for calculations etc. But when I use the "...
4
votes
0answers
67 views
+50

Problem executing vectorgrid (from processing) in a standalone script using QGIS 2.8.6

I have the following piece of code which I execute within QGIS 2.8.6 import processing import ogr restrLayer = QgsVectorLayer("/home/usr/Desktop/trial/EligibleAreas_polygons_filtered.shp", "...
2
votes
1answer
111 views

Finding list of all shapefiles that overlap with single shapefile using QGIS?

I have a list of 34 shapefiles. These shapefiles are range maps for different species. I would like to take 4 of these shapefiles and document a list of those shapefiles (within the 30 shapefiles), ...
2
votes
2answers
58 views

Add attributes to layer

I'm trying to add a new attribute to a vector layer in my plugin. But it does not work.. Why? selectedLayerIndex = self.dlg.comboBox.currentIndex() selectedLayer = layers[selectedLayerIndex] name = "...
1
vote
0answers
20 views

Compare symbols in pyqgis

I'm working with renderers and I want to compare symbols from two different renderers. Is there any way to do it in pyqgis/python? Here is how I get symbols: renderer = layer.rendererV2() category = ...
5
votes
4answers
2k views

How do I rename Shapefiles in QGIS?

I have a huge list of layers in a project that are named in a foreign language. I want to translate and add the English title to the name. When I right click on a layer and choose Properties -> ...
1
vote
1answer
28 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 ...
2
votes
1answer
144 views

QGIS crashing/failing when dissolving multiple shapefiles in a Python loop

I am using QGIS 2.10 (but I've also tried 2.8) to loop through all the shapefiles in a folder (those ending in .shp) and perform a dissolve function on each of them. However, when I run the following ...
1
vote
0answers
16 views

How to dynamically move a polygon in map canvas?

I would like to dynamically move a polygon on QGIS map canvas with a python script. The polygon coordinates are updated every n seconds in txt file by an outside application. I tried the following ...
-1
votes
0answers
26 views

How to programmingly get the feature from a layer by the feature's ID in Python QGIS? [on hold]

I have get a list of polygon features' ID, I want to get the corresponding polygon features by these IDs in the layer, then if I want to do some calculations by using the polygon's geometry. How can I ...
11
votes
1answer
335 views

PyQGIS save raster as rendered image, then use GDAL tools on it

I have tried to use the code from QGis Save Raster as Rendered Image. i is a raster layer: pipelayer = i pipeextent = pipelayer.extent() pipewidth, pipeheight = (pipelayer.width(), ...
0
votes
0answers
31 views

Amending existing plugins to match Qgis 2.16+ fTools removal

Part-time development started about a year ago to create an add-on for Qgis. Many of this plugins capabilities are written with fTools commands. I am wondering if there is a recommended document to ...
2
votes
1answer
36 views

Wrong nearestNeighbor result

Could somebody tell me what is wrong with this code? This is a part of my script and returns totally different result from "Nearest Hub" with the same line and point layers. I would like to identify ...
6
votes
1answer
2k views

How to identify and highlight features programmatically?

In QGIS there is an option to select features of a selected layer using a "identify feature" tool. Then the feature get highlighted in a different color and attribute dialog is poping up. like that i ...
0
votes
0answers
24 views

Is it possible to create a standalone dbf table with pyqgis

I have written plugin that grabs tabular data via soap requests. As of now the results are written to a csv file. I would rather the results go into a dbf to retain numeric values for a variety of ...
4
votes
2answers
164 views

Convert vector point data (shp) to raster (tif) using QGIS

Overall Question: How can I get the rendered tif image to keep the modifications seen in the image produced by map canvas? I am writing a standalone Python script. I have simplified my code below ...
0
votes
3answers
463 views

How to make line with arrow head in QgsVectorLayer using python?

I need to draw line with arrow head or after drawn the line i need to make it as arrow head line by using python. or can we set any arrow head symbol for line features by using python? Kindly help me ...
1
vote
1answer
18 views

Problem with QgsMapCanvas().zoomToSelection() when running from function

I have the following function which, when typed in to the python console line for line works fine, but when I use the function it gets as far as highlighting/selecting the accident (feature) but the ...
2
votes
1answer
65 views

How to create azimuth raster layer by pyqgis?

I want to create an azimuth raster layer base of single point shapefile, for this I write below code that create a memory point layer that each point in memory layer is center of each pixel and have a ...
2
votes
0answers
16 views

pyQGIS: Which attribute change signal should I listen to?

I want to receive a signal when changes have been made to a layer, regardless of the type of editing (add features, remove features, change attributes). When I receive this signal I export the layer's ...
0
votes
0answers
16 views

pyQGIS: strange error message for QgsMessageLog.logMessage()

I emit some log message in a QGIS (2.16.0) plugin I'm writing: self.log("Selected layer " + self.layer.name()) def log(self, str): QgsMessageLog.logMessage(self.toolbar.objectName() + ": " + str,...
0
votes
0answers
32 views

PyQGIS & multi selection request [closed]

How I can do to iterate over a layer in order to select the all value of one parameter and add it into a table (without redondancy)? I am a beginner using QGIS and especially Python for QGIS. I ...
1
vote
3answers
49 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....
1
vote
1answer
15 views

QgsVectorFileWriter returns false output

I am trying to make a script that reads the content of a .dbf-file and exports it as a shapefile. Equal to the manual pattern "Save as.." when rightclicking the imported layer in the Qgis Desktop. I'...
2
votes
1answer
254 views

Apply graduated symbology renderer works in Python console but not in standalone script

I use the following PyQGIS script to load a vector layer from a shapefile and apply graduated symbology to it (tried to make it as minimalistic as possible). This works well in the QGIS 2.4 Chugiak ...
2
votes
1answer
279 views

How to apply categorized symbols to polygon layer with PyQgis?

I'm fetching a polygon layer from postgres using the following: uri = QgsDataSourceURI() uri.setConnection("localhost", "5432", "mydb", "postgres", "xxx") uri.setDataSource("public", "my_table", "...
2
votes
1answer
138 views

How to change default symbol in Categorized symbol renderer (python console) or use different icons as vector layer symbols?

I have a point shapefile in QGIS 2.10 and I want to display one of its fields attributes based on its unique values (I always know that it has 4 unique values and their values so I do not care for the ...
2
votes
0answers
35 views

QGIS 2.8 & Python: Merge problems using Python

I have 9 vector layers that I rasterized. All of these have the same: x;y origin pixel size (1 pixel=1 meter) SRS When displayed separately in QGIS these 9 rasters are superimposed correctly but ...
0
votes
1answer
226 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....
1
vote
1answer
24 views

How do I control the behavior of the QMessageBox

I'm working on my first plug-in. In an attempt to validate the user selections on the dialog, I am using a message box to return messages to the user if an error is found. The messgae box displays ...
1
vote
1answer
49 views

How to overwrite SHP layer

I'm modifying the Arrows plugin by Gregoire Piffault. It writes the output to a shape file, but if the shapefile already exists it fails. He tries to remove the file using QgsMapLayerRegistry.instance(...
2
votes
3answers
991 views

QGIS install on Ubuntu 14.04 fails

Following the QGIS installation guide I have tried both UbuntuGIS and QGIS stable, but both fail with the error message: The following packages have unmet dependencies: python-qgis : Depends: python-...
1
vote
1answer
52 views

How to Format QGIS Field names on Editor Form

I am using PostGIS table in QGIS with custom QGISFieldWidgetFactory. However, I wanted to rename the field names in QGIS Edit Form from say first_name to First Name using Python. Currently, I was able ...
1
vote
2answers
116 views

Creating polygon grid with un-even spacing between research plots?

I have an orthomosaic of a crop field with small research plots (3.8 X 1.44 m and 0.22m b/w plots and 0.50m b/w range spacing). I would like to create a polygon layer using this information. After ...
0
votes
1answer
24 views

segfault on exit when map layer has connection to “layerRemoved”

Here's my sample code that shows the problem - apologies if this is a big load of code but this is as minimal as I can get it: import sys from qgis.core import * from qgis.gui import * from PyQt4....
1
vote
1answer
28 views

How to enable “Label every part of multi-features” with pyQGIS?

Regarding the 'Label every part of multi-features' check box located in the 'Labels // Rendering // Feature Options' layer properties UI... Can this be done with pyQGIS? These two commands enable ...
1
vote
1answer
29 views

C-based implementation of Djikstra's or Fast Marching for QGIS/Python?

I need an algorithm to find least cost paths between points on a discrete grid, allowing for the direction of transport to affect the cost of transport, allowing for different modes of ...
1
vote
1answer
23 views

Loading style (*.qml file) to layer via PyQGIS?

Is there any way to load a *.qml file to layer and set a style to it in python (pyqgis)? Can I 'get into' this file in console? I want to review it.
2
votes
1answer
114 views

External Standalone QGIS Application with Default Toolbars? [closed]

I want to develop a standalone application and add the default digitizing and advanced digitizing tools in QGIS as-is on my application through PyQGIS. Is it similar the way you add the navigation ...
2
votes
1answer
154 views

The QGIS atlas defined with pyqgis and a QPT template exports the same maps

I need to generate an atlas for each feature from a layer for reporting. There will be created a few maps. The centre of each map must be focused on each feature. In this task I use a predefined QPT ...
3
votes
1answer
429 views

Retrieve a point coordinates from map canvas using QGIS API

I'm trying to build a plugin that firstly captures the map coordinates. I have tried to adapt the map tool explained in this post: How to programatically check for a mouse click in QGIS The code I ...