Python bindings for QGIS.

learn more… | top users | synonyms (1)

6
votes
3answers
109 views

Counting number of vertices of object on vector layer PyQGIS

First of all, I want to say that I know that similar issue was raised before, but it didn't provide satisfying solution. I need to get the number of vertices of every object on vector line layer. ...
4
votes
0answers
44 views

How do I implement PyQGIS multithreading to update a progress bar

I am developing a PyQGIS plugin using python. I facing a problem during the implementation of threading in my plugin. I have written a python script which contains a class wrapping all geo-processing ...
3
votes
1answer
59 views

Build a table with columns of raster values from multiple raster datasets, using Python, GDAL, or PyQGIS?

I have a series of raster datasets, clipped to the same extent, with matching cell resolutions, each of which represent land surface temperatures (LST) captured by the MODIS sensor. Each raster ...
1
vote
1answer
99 views

AttributeError: 'NoneType' object has no attribute 'dataProvider'

I want to add new column to attribute table of vector layer via Python console. I'm trying to do this following instructions from ...
6
votes
2answers
191 views

Adding all Binary Rasters in a Directory Using Raster Calculator in a Standalone Python Script

I have a directory with binary raster files (1 band only) which I need to add in a standalone python script. The problem is the rasters have different number of rows and columns and different ...
2
votes
1answer
54 views

Set CRS for Raster in QgsRasterLayer (pyqgis)

in a QGIS python plugin I get some code that writes a asc file, this is the header of the final file: NCOLS 20 NROWS 15 XLLCORNER 664400.000000 YLLCORNER 4749500.000000 CELLSIZE 100.000000 ...
1
vote
1answer
62 views

HTML Annotation using pyqgis

I really like the html annotation tool in QGIS. My plan is to show a photo (web based image// jpg) on each point of my point shapefile. Unfortunately labels don't work as they do not parse HTML and ...
3
votes
2answers
124 views

Deleting polygons with certain height and width in Python script with QGIS?

I have a polygon layer with bounding boxes (boundingLayer). This layer has attribute columns "HEIGHT" and "WIDTH". I want to delete all bounding boxes which have HEIGHT and WIDTH less than 200m. How ...
1
vote
0answers
22 views

Testing Oracle query produces valid results in QGIS Python Console

I have a query that searches an Oracle database using a where clause to get the geometry of an object and then zooms to the extent of that object. The value for the where clause is retrieved from a ...
1
vote
2answers
45 views

How to insert attribute in a selected feature from active layer (PyQGIS)

I want to update some fields from a selected feature in an edit session with some values provided by a form made in QtDesigner. The fields have indexes 0 and 2. Tried so far: from edit_Form import ...
2
votes
1answer
49 views

Problem with calculating QGIS Zonal Statistics MEAN

I need to calculate some zonal statistics from raster files for some polygons in a shape file. I am using the following code which works: eligibleLayer = ...
1
vote
1answer
69 views

How to define a point by coordinates in QGIS (Plugin)

I am developing a QGIS plugin and got currently stuck at setting the geometry of a feature based on coordinates. I retrieve coordinates through an SQL query, create a feature and try to set the ...
2
votes
1answer
59 views

How to sort layers within groups with Python?

After running a longer script (Qgis Console), all I want to do is sort the layers within my groups; since some of them are buffers and the 'biggest' buffer is now on top. I've tried stuff based on: ...
0
votes
0answers
37 views

Work values of a table in QGIS!

I have a table associated to a shapefile with the number of people who live in different villages and the corresponding city. I want to define a new shapefile with points located in the centroide of ...
3
votes
1answer
54 views

QGIS standalone application for map rendering: bad extent

I made a simple standalone QGIS app for rendering a set of layers and export it as a PDF file. When i use iface.mapCanvas().mapRenderer() (inside QGIS console) for rendering, my output is OK. If i ...
1
vote
1answer
34 views

How do I get the feature id after featureAdded signal (PyQGIS)?

I'm trying to make an edit form in QGIS (Python code) ,and i want after feature drawing to get the id, and the feature to be selected. Do you have any ideas to do that? Tried so far: ...
1
vote
0answers
26 views

QgsFeatureRequest with expression on joined fields in pyqgis

I have a shape layer in a QGIS 2.8 project with fields A and B joined to a Oracle database layer with field C. I am writing a plugin to search the shape for fields A, B, and C. I am doing this with ...
0
votes
1answer
71 views

Python code to import OSM data in QGIS

I am trying to automize the workflow: import osm data and select by a special tag. I have to do this steps a lot of time with different parameters and updated data. A Solution could be a python ...
3
votes
1answer
120 views

Script to save lots of shapefiles into different CRS in QGIS

I have a lot of shapefiles that I need to save in a different CRS... is it possible to automate this process with a script in QGIS?
2
votes
1answer
78 views

Calculate area of all polygons in a shape file and save it in attribute column “Area” in a python script using QGIS

I have a shape file with about 2000 polygons. I am using QGIS and I need to write a standalone python script which opens the shape file and calculates the area of all polygons separately and outputs ...
4
votes
1answer
104 views

Problem Editing a Vector Layer QGIS

I have a vector layer which I need to load and edit (add several attribute columns). I am doing this without opening QGIS, so within a python script. I have the following piece of code for the layer ...
4
votes
2answers
90 views

Retrieve available PostGIS connections in PyQGIS

Can I retrieve the available connections to PostGIS databases in PyQGIS? I would like to provide a list of available db-connections, and subsequently a list of tables within the ui of my plugin. I ...
0
votes
0answers
14 views

Id allocation of QgsFeature objects

I noticed a strange behavior when creating a new QgsFeature object and adding it to a layer, inside a QGIS plugin. Let me first briefly explain the structure of my plugin: I have a main function that ...
2
votes
0answers
15 views

PyQgis - How to update a spatial index?

I am trying to speed up a QGIS plugin I wrote by adding a spatial index to a vector layer. The aim of my plugin is to simplify a line network by merging some of its features, based on some criteria. ...
2
votes
0answers
62 views

Create a layer, edit and save. Where are my features?

I created a layer (e.g. point) in QGIS with QgsVectorLayer from memory: mem_layer = QgsVectorLayer("point?crs=epsg:32630&field=id:string","TempFile","memory") ...
3
votes
0answers
66 views

How to create a shapefile having Voronoi diagrams from the shapefile of an existing region?

I have a shape file of a region and I want to generate random sub regions of that shape file using Voronoi class of scipy.spatial package of python. But I am a newbie to GIS. I found out about Voronoi ...
3
votes
0answers
47 views

QgsSpatialIndex partial or complete overlap

I'm working on adding some functonality to a QGIS plugin. It currently uses a QgsSpatialIndex to efficiently compute whether the features of a vector layer intersect (potentially millions) of ...
2
votes
1answer
48 views

Extracting zeros from numpy array and creating a new raster

The following code reads in several .tif files from an input folder, converts them to numpy arrays and adds them together. All input files are binary: inputFolder = "/home/usr/Desktop/BufferFolder/" ...
2
votes
1answer
36 views

Importing Several Raster Layers, Doing Manipulations and Exporting The Newly Saved Rasters

I have the following code: src_ds = gdal.Open("/home/usr/Desktop/RasterFolder/Name.tif") if src_ds is None: print 'Unable to open %s' % src_filename sys.exit(1) myarray = ...
2
votes
0answers
46 views

module object has no attribute classFactory

I asked this question several days ago on the QGIS developer list but didn't get any love. I'm hoping someone can help me resolve this error. I have a custom repo and a custom plugin that I'm ...
4
votes
1answer
48 views

How to toggle group visibility in QGIS using Python?

I've tried this, but it doesn't work out. root = QgsProject.instance().layerTreeRoot() group1 = root.insertGroup(0, "PGB") legend = i.legendInterface() legend.isGroupVisible(group1) ...
2
votes
1answer
69 views

QGIS - PYQGIS Import gpx as vector layer

I'm trying to use the python console to import some gpx files as vector layers. When I do it manually I have to choose which layers to add, my options are: I've tried various versions of the code ...
1
vote
0answers
53 views

Cannot import name QtTest running unittests for QGIS plugin

I have the following imports in my unittest code: from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4 import QtCore, QtGui, QtTest When I run my unit test from the command line I get ...
3
votes
1answer
69 views

azimuth and distance from various functions in qgis

I am comparing the various ways of calculating distance and azimuth between two points with Qgis. I am struggling with the various results and their interpretation. I need to calculate a loxodromic ...
1
vote
1answer
64 views

QGIS Zonal Stats Plugin - Python Console - compute one specific statistic

I think this is more of a syntax problem that I have here. But I am absolutely not able to figure it out. On a different Linux machine I got the following working: zoneStat = QgsZonalStatistics ...
4
votes
2answers
69 views

performance problem with PyQGIS: manipulating attributes

I have selected a vector layer with attributes slope and area. I want to combine all the features with slope 0 to 5, 5 to 10, ... , 85 to 90. The original features are to be discarded, and new ...
2
votes
1answer
110 views

Huge file size after averaging two rasters

After I average two raster files (singleband gray, initial size ~700MB each) through QgsRasterCalculator() with formula "Raster1@1/2 + Raster2@1/2" the size of the resulting file is 2.9GB. Is there ...
3
votes
1answer
119 views

Automating QGIS project composer printing?

I have a large project which consists of around 10x QGIS project files. Each project contains a print composer with an atlas set up to generate up to 10 maps. What is the easiest way to automate the ...
2
votes
1answer
59 views

How to display different layers with different CRS in one canvas in a standalone application?

I am a freshman of the pyqgis. Now I load the raster and vector data in the standalone application. The two data are same area, but in my canvas, they are at different places. I want to know how to ...
2
votes
1answer
53 views

iface.addVectorLayer on a gml file causes “Select vector layers to add” dialog (pyqgis)

I am trying to load a directory full of zipped GML files (*.gz) into QGIS using pyqgis' iface.addVectorLayer(), but as the GML file contains multiple separate vector layers (Area, Text, Symbol, Point ...
2
votes
1answer
41 views

How to use a SLD file from the QGIS console?

How to apply a SLD file to a layer in QGIS from the QGIS console? I tried this but it didn't work: # selecting the layer layer = iface.activeLayer() # Apply SLD on the layer ...
3
votes
2answers
83 views

Trying to use LIKE in an expression in pyQgis

I want to select elements from a layer. The field I use is a string/character field. My code is as follows: expr = QgsExpression(ur'"myField" = \'valueILookFor\'') it = ...
2
votes
1answer
42 views

pyqgis - Editing a feature - Is it possible to set a listener?

is it possible to set a listener that is fired when a feature is edited? What I imagine is this: A geometry is edited (e.g. cut operation) then a listener is fired. This event gives me back the ...
2
votes
1answer
58 views

Why is QgsFeatureIterator returning bad data?

This is a spin-off of another question I asked previously, but it has grown in scope and deserves its own thread. While iterating over a vector layer (shapefile) I included the following ...
2
votes
1answer
59 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
32 views

How to iterate through attribute visibility with PyQGIS?

I have a point shapefile with a timestamp that I would like to turn off and turn back on 1 by 1 with a new element of the attribute table appearing every second
2
votes
1answer
58 views

IPython plugin not loading in QGIS 2.12

I am trying to run the IPython console plugin in QGIS 2.12 After installing the plugin there is this error: You need to install IPython 3.1.0 (and then restart QGIS) before running this ...
1
vote
1answer
39 views

rendering a single band raster - new maxvalue

I have a downloaded raster file, singlebandgray, and want to redefine it's maximum value to a higher integer value. Via the QGIS desktop it works smoothly by hand via the Properties. Via Python I was ...
2
votes
1answer
40 views

Actions undertaken in QGIS somewhere stored as Python code in a history file?

For practioners that are not willing to study all the methods for each class, it would be helpful if every action that was made within the QGIS interface can be looked up afterwards in a history file ...
3
votes
0answers
67 views

Python script to automate saving satellite images for different combinations of lat longs

PS. : This is my first try at a GIS application. Please forgive if my question is pedantic. I would like to get a series of satellite images all at the same scale centered around different points on ...