Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
31 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
22 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
37 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
110 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), ...
1
vote
2answers
52 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
18 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
1k 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
26 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
140 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
13 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
20 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
328 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
25 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
34 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
21 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
149 views
+50

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
462 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
16 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 ...
1
vote
0answers
14 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
13 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
31 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
0answers
31 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....
1
vote
3answers
48 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
13 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
253 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
276 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
136 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 ...
1
vote
0answers
34 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
225 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
47 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
984 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
48 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
23 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
25 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
427 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 ...
1
vote
2answers
28 views

When selecting input don't minimize window - pyqgis

I am making a plugin and I have a window in which you have to select an input file. There is a pushButton and lineEdit. I am typing a path and when clicking OK button to go back to window it ...
2
votes
1answer
239 views

How to remove a layer and its legend in a standalone pyqgis application?

In continuity in my question How to add a legend to a canvas in a standalone PyQGIS application? > In every addition of a new layer in my standalone application, the legend lengthens and becomes ...
1
vote
1answer
19 views

Modifying Font Style simple marker according to character value

Currently I am writing a standalone Python script and I am trying to modify a simple point marker using font style. There are some interesting fonts with different characters that aren't exactly on a ...
0
votes
2answers
19 views

Python code execution error in QGIS WIEN

I have tried to make several different actions in QGIS but keep getting similar error messages when I try to select the output filename. The error message reads as follows: An error has occurred ...
3
votes
1answer
90 views

Setting default label font in QGIS?

QGIS currently does not have a way to set a default font to be used for labelling, and being lazy I'm getting tired of having to set our house font styling for every layer I create or use (see change ...
1
vote
1answer
17 views

PyQgis show SVG Symbol on differnet value of specific attribute

I am working on a QGIS plugin. Main feature of this plugin will be changing the icons on a specific layer partly based on a specific attribute (it will be more exciting but you have to start somewhere)...
1
vote
0answers
25 views

Problem with pushButton handling - pyqgis

I have made a pushButton - new window relation. Now, when I'm trying to 'link' methods with pushButtons in new window they don't react. Here is what I wrote in metod, which opens new window in ...