Python bindings for QGIS.

learn more… | top users | synonyms (1)

11
votes
1answer
323 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
8 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
33 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
18 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 ...
3
votes
2answers
135 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 ...
1
vote
0answers
9 views

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", "...
0
votes
3answers
461 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
15 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
13 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
27 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
275 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
135 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
33 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
224 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....
0
votes
1answer
22 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
46 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
981 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
45 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
22 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
27 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
91 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
1answer
21 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
153 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
426 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
0answers
18 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 "...
1
vote
2answers
27 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
238 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 ...
0
votes
1answer
16 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
18 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
89 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 ...
0
votes
1answer
16 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)...
0
votes
1answer
47 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 = "...
0
votes
0answers
23 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 ...
1
vote
0answers
34 views

Split polygon using points and their directions with python

I`m new for the python but want to split Voronoi polygons using points and their directions as input. Voronoi polygons were created by in-built tool: Vector>Geometry Tools>Voronoi Polygons from layer ...
0
votes
0answers
34 views

GeoJson Vector layer in QGIS from a WFS service

It is possible to specify the outputFormat=geojson for a qgis wfs layer? By default, when I add a wfs layer in QGis, is downloaded from geoserver as GML. If I create the layer as: uri = "http://...
2
votes
2answers
47 views

Projection: conversion of coordinate pairs in Python

Google Translated I am using QGIS and wish to automate the export of a map (an existing project) to which I add a vector layer (representing a construction zone) in pdf format. The problem is: The ...
0
votes
1answer
19 views

Find out if checkbox checked - pyqgis

I'm new to pyqgis and I'm not sure how can I find out if checkbox is checked and according to the result do different things in another method? I know how to do it in theory, but if someone can show ...
5
votes
1answer
67 views

Sending a https request from a QGIS plugin using urllib2

I'm developing a QGIS plugin that needs to send https request to an API. I have to use urllib2 (see below if you want to know why I don't just use the requests package) The first request I need to ...
0
votes
2answers
52 views

When buton clicked, open new window - pyqgis

I'm making a plugin which has two windows. What I want to know is how to refer pushButton in one window to method which opens new window. I have dialog *.ui files for both windows and their *.py. ...
1
vote
1answer
82 views

What solutions to use QGIS as insert tool for a Postgres relationnal database?

I have a Postgres/PostGIS relational database and I would like to use QGIS as an interface for inserting data. The thing is that my database is quite complex and I need my tool to handle the following ...