Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
6 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 ...
0
votes
0answers
13 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/" ...
1
vote
1answer
21 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 = ...
1
vote
0answers
10 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
37 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
40 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
40 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
42 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
37 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
53 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
97 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
84 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
51 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
31 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
25 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
70 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
29 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
41 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
47 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
31 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
45 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
31 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
39 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
56 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 ...
5
votes
2answers
106 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 ...
-2
votes
0answers
28 views

Generate equal sized polygons along a line with PyQGIS [duplicate]

One month ago I asked a question about how to generate equal sized polygons along a line in QGIS, which seems to be also interesting to a bunch of people aside from me (20 upvotes and more than 400 ...
1
vote
0answers
17 views

how to generate a raster with its spatial reference from an array(or matrix) by using pyqgis

I used arcgis to generate rasters from txt files by a certain python api,but i am not familiar with qgis,and now i need generate some rasters from txt files by using pyqgis.The resulting rasters ...
1
vote
0answers
26 views

Python QGIS - How to add the classic edit Menu in the Menu Bar

I am doing a QGIS application. Here is the plan: I start QGIS with no menus, toolbars, panels, etc. With nothing ! For that I have modify the QGISCUSTOMIZATION.ini With a plugin who start with QGIS ...
1
vote
1answer
55 views

How to set conditional imports for a PyQGis script running inner or outer of QGIS?

Related to Cannot run standalone QGIS script I try to detect if my script is run from a QGIS instance (through the plugin) or from a standard python console. This detection will enable conditional ...
2
votes
1answer
39 views

Working Windows Standalone .EXE From QGIS Python Script Using PyInstaller?

Has anyone been able to create a working standalone Windows .EXE file from a QGIS Python Script Using PyInstaller?
6
votes
1answer
75 views

Calling PyQGIS functions from external editors (Linux)

Is it possible to integrate external Python editors (such as KDevelop) with QGIS, so that it would be possible to run functions in qgis.core, qgis.utils etc. outside of the QGIS Python Console? ...
1
vote
0answers
24 views

python handling case in address (lowercase,uppercase) [closed]

I'm working on a python QGIS plugin that takes address info from specific parcels and lists it. The data is in various cases and I'm having a hard time figuring out how to handle it. My data looks ...
1
vote
0answers
28 views

QPyNullVariant not recognized outside of QGIS

So here is a weird one. I'm getting an error about an operation involving a QPyNullVariant: TypeError: unsupported operand type(s) for *: 'QPyNullVariant' and 'float' So I wanted to put a check ...
3
votes
1answer
75 views

PyQGIS couldn't import processing with standalone script

I have read post on that problem (How can I access `processing` with Python?). The problem is even with a sys.path.append it couldn't import processing. It's very frustrated. Here the code I used: ...
2
votes
1answer
27 views

PyQGIS: Change attribute value doesn't work, results in NULL

I am writing a QGIS plugin, which at one point attempts to change several attribute values on a layer. However, in the end no changes are made. If I punch similar code into the built-in Python ...
4
votes
1answer
33 views

Merging Features

I want to merge features of a vector layer into one single feature using the python console. Somewhere I found the following solution. However it does not seem to work for me. When I execute the ...
3
votes
1answer
50 views

Qgis Python: Find bounding box for multiple features?

I want to find the bounding box of several features selected by their attributes. Here's what I've been trying: tNumList = [8,9,10,11] selectGeom = QgsGeometry() for tNum in tNumList: request = ...
3
votes
1answer
68 views

Showing QgsAddAttrDialog in a Python plugin

I want to invoke the builtin add field dialog from my python plugin in QGIS: This is the add attribute dialog of the attribute table. It is located HERE. I expect it to return a QgsField. ...
3
votes
1answer
66 views

Get results from using GRASS algorithms with the QGIS processing tool

I am trying to write a plugin in QGIS that uses at some point a GRASS algorithm : "v.split.length", accessible by using the processing class, and here is how I am using it : ...
7
votes
0answers
169 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(), ...
4
votes
1answer
59 views

Troubles Updating Values of Selected Features with PyQGIS

I'm trying to modify the values of some selected features. I have written this small script, but nothing happens when I run it. Is there something that I've missed? Here is my code. lyr = ...
3
votes
0answers
50 views

Can qgis_core work with external python distribution (such as Anaconda)

I've built a python application that has its own GUI. I am trying to use qgis.core/pyQgis as map display only. Specifically, i have anaconda 2.3 and its python distribution (2.7.11). After research on ...
3
votes
1answer
76 views

Standalone python app that uses qgis.core without installing qgis

I am building a standalone python application that has its own GUI, i would like to use qgis.core/pyqgis as a map display only. But from my searches on this topic, it seems that the full QGis software ...
0
votes
0answers
24 views

How to run a function in a while loop while an QObject is activated/triggered in PyQgis

Firstly I am new to PyQgis and there might me a lot of basic errors. The aim is that everytime a new vector object is drawn its attribute should automatically update while a QAction I have created ...
1
vote
2answers
54 views

How to define outline color from polygon layer using Python?

I´m using a QGIS 2.8.3 and I want to define a style for the legend of my polygon layer. I was using this code that works perfect: str1= 'C:/Documents/Layer.shp' myVectorLayer = QgsVectorLayer(str1, ...
3
votes
2answers
77 views

How to Check if a Layer is PRESENT or ABSENT in a Project via PyQGIS?

In QGIS, what is the simplest python code (least possible) to verify if a particular layer is PRESENT or ABSENT in the Map Layers list? NOTE: The script shouldn't trip an error IF the layer is ...
1
vote
0answers
41 views

Try/Except Statement gives different Results in QGIS Console vs. QGIS Tool

I want my script to do different things depending on whether a particular layer DOES or DOES NOT exist in the Map Layers list. I thought the try: / except: statements would be the best way to achieve ...
1
vote
1answer
33 views

How to add a layer using actions in PyQGIS?

I'm learning to use the python console within QGIS. I want to add layers like iface.actionAddOgrLayer(), open projects and more by the action-function, but without any response - only the string ...
1
vote
1answer
26 views

Render QgsRasterLayer without adding to legend

I am trying to render a number of related QgsRasterLayer objects that are related to eachother (they are slippy-type tiles). Ideally I would like one item in the legend that can have its position ...
6
votes
1answer
74 views

Adding PostGIS layer from QGIS Python plugin

I try to develop a plugin to add postgis layers to qgis from a plugin as part of learning python. The code for adding a postgis layer is taken from the cookbook and work fine if I run it from the ...