Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
103 views

Creating set of maps (PDF) using QGIS and Python with WMS Data

For a scientific project I am trying to create a set of PDFs in QGIS with a fix layout (in the print composer) but per PDF a) different map item attributes (extents) and b) a QR-code to identify this ...
3
votes
1answer
111 views

Split feature by line in PyQGIS

My objects are a polygon and a line. I want to split my polygon according the line. I have used reshapeGeometry and splitGeometry with no success. ReshapeGeometry returns 0. Polygon-foo foo = ...
3
votes
1answer
53 views

Unable to print anything or write anything to file in python after importing processing

I've been trying to get standalone QGIS python scripting to work, but for some reason after I import processing, I cannot print anything to the console, nor can I write anything to file. My end goal ...
1
vote
1answer
52 views

Random sample from selection

I have a selection in vector point. I would like to do random sample from it. I am using qgis to do it. Here is my selection code: ...
2
votes
1answer
113 views

Load a GeoJSON layer with QGIS's Python module

I have been able to load a GeoJSON file into QGIS by simply clicking "Add Vector Layer", and selecting my file to load. Now I'm using the qgis.core Python package, and I'm trying to load the GeoJSON ...
2
votes
0answers
27 views

QGIS plugin window qt creator formatting ineffictive

I am developing a QGIS plugin. I have assigned the QGIS main window as the parent window of custom plugin using: QtGui.QDialog.__init__(self,iface.mainWindow()) But after doing so the problem ...
1
vote
0answers
24 views

QgsCategorizedSymbolRenderer default ramp colors

I have a plugin and I want to symbology a vector file with some default ramp colors but I see that in graduated symbology is not so easy as in graduated symbology. Is it possible to assign a default ...
2
votes
2answers
364 views

Return list of selected items of QListWidget PyQt QGIS

I'm a little bit confused (I'm a newbie) on how to get a list of just the selected Items of a QListWidget (in a QGIS plugin). I set up the manageGui function in this way: def manageGui(self): ...
2
votes
1answer
77 views

Displaying RGB raster on QGIS with no enhancement with Python Console?

I'm working with a RGB raster on QGIS 2.6.1, on a Windows 7 machine. I need to set the Contrast Enhancement option to No Enhancement with the Python Console (not through the Layer Properties ...
1
vote
1answer
77 views

Pyqgis : how to close composer window?

I would like to load new composers from template files (*.pqt) when I open my plugin. I managed to do it using this helpfull post Programmatically import new composer from template to project using ...
3
votes
0answers
84 views

spatial index intersection with qgsrectangle only computes polygones

I have the problem, that i only get polygon features inside my defined rectangle. If i switch off my polygon layer(s) i get my lines. TOC: Line-Layer on, Polygon-Layer on: i only get Polygons which ...
5
votes
1answer
239 views

Do I have to publish own QGIS plugins?

If I develop QGIS plugins for my company do I have to make them available to others? I use QT-Designer and think that it also depends on the question how you develop your plugins, right? For example: ...
3
votes
1answer
145 views

Has the “Warp (Reproject)” tool changed in QGIS 2.12?

I am writing a QGis plugin, for QGis 2.10, which imports processing 2.10.3, that needs: testproc = processing.runalg('gdalogr:warpreproject', thisName, # input ...
4
votes
1answer
120 views

Drawing polygon in qgs map canvas

I want to make a custom application which includes an option just like the "Select Features by Polygon" feature in the qgis. I am able to draw the polygon using following code: self.rb = ...
1
vote
1answer
70 views

PyQT: QFileDialog keeps on opening window after clicking on cancel or ok

I use to write QGis plugins, which is based on PyQT. I use to create QButtons and connect their click to a function that itself calls a QFileDialog. For example: def doOpenFile(self): fname ...
1
vote
0answers
98 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 ...
6
votes
2answers
246 views

Skeletonize vectors in QGIS/Python

I am trying to find a tool to create a skeleton of a large vector dataset using QGIS and its bundle. It should be directly programmatically callable through Python or commandline (QGIS, GRASS, OGR ...
0
votes
0answers
42 views

Memory issue? qgis python processing does not complete

I have a simple process to make some edits to all the contour files in a directory. It runs fine on the test of 100 odd files but in a directory with about 500 it stops after about 120 files. Is ...
1
vote
1answer
47 views

store function attribute of class in QGIS plugin

I'm pretty new to python and pyqgis so the question will be pretty trivial.. I'm writing a plugin and in one script I have a class and some internal functions.. .... class ...
0
votes
1answer
52 views

Spatialite function to generate a blob from a geometry

Using QGIS Python API, I want to avoid updating geometry with an UPDATE sql command. Why? I'm using a QSqlRelationalTableModel (see model-view programming if curious) and there are built-in editing ...
2
votes
1answer
34 views

Open CSV with native QGIS Widget

I am writing a plugin that offers to open a CSV. I know the local path to the CSV but I don't know if it contains spatial data nor which name the X and Y could have. The best way I can think of, is ...
2
votes
1answer
81 views

QGsComposerLabel set text

I am building a composition with map, legend... I want to add a paragraph (text) to the composition but the text only recognize one word. What I am doing wrong? Code: text = ...
1
vote
1answer
47 views

setHeaderData not working in a QgsAttributeTableModel?

I want to display the content from a layer in a new view I have so far a code like below (you should have 2 columns at least, then, just try in the QGIS Python console replacing mylayer_id) from ...
2
votes
3answers
118 views

Running PyQGIS script in Windows

I'm not able to run the following PyQGIS script in Windows (it worked perfectly in OS X): import sys import os from qgis.core import * import qgis.utils from qgis.analysis import * app = ...
1
vote
1answer
48 views

How can a gui be visible till all the work is done? (QGIS plugin, python)

I have made a gui in QTDesigner for QGIS2.10 (as a dialog). When I press the ok button (if result == QtGui.QFileDialog.Accepted:) everything works just fine but the gui is disappeared. How can the gui ...
5
votes
1answer
106 views

Create a temporary intermediate layer in a processing script

My algorithm needs a temporary layer in a QGIS processing script. I can use regular pyqgis api to create a temporary layer but want to know if there is a preferred and processing-specific way of doing ...
1
vote
0answers
59 views

Creating spatial layer from MS SQL Server table?

I have a table in MSSQL that I am trying to use to create a spatial layer from using the QgsVectorLayer function to load the table as a layer, and then using Fiona to create a shapefile but I am ...
0
votes
0answers
57 views

GDAL error in QGIS application displaying VRT files

I am working with a standalone app build with QGIS 2.8.1 on a CentOs7 machine. I got a new DTED data set which raises errors "somewhere" in the app. The app doesn't read the .dt? files directly, but ...
4
votes
1answer
125 views

Converting Python script for QGIS?

I am still a novice in python, but I have the long term goal to create a plugin one day. The first step to this plugin is a test with QGIS python scripts to convert an Access mdb into sqlite db and ...
1
vote
2answers
114 views

QGIS 2.10 Unable to add features to a memory layer

I'm trying to add features to a memory layer. This is the layer creation : memlayer=QgsVectorLayer("{zr_typegeom}?crs=epsg:4326".format(zr_typegeom = typegeom), "memlayer", "memory") ...
1
vote
0answers
51 views

qgis modeler - use input filename in output filename

I need to use the input filename in the output filename in a qgis model. I have spent a couple of hours trying to find a solution but can't. If the input is contourXY.tab and I want output to be ...
1
vote
1answer
97 views

Change attributes values?

i want to change attributes values in a memory layer. I already asked a similar question but i'm re-stuck on the problem and don't find any solution to this basic need. Here is what i'm doing so far ...
1
vote
1answer
135 views

Pretty table python module with variable number of rows [closed]

Is there a way to produce a table in a txt file using pretty table python module, using an i variable for the row count for the case I do not know the number of rows from the begining? For example I ...
0
votes
0answers
31 views

How to Query the WFS layer with points(coordinates from mouse click) to get the xml data in QGIS using python

I am using the following syntax to load the WFS layer: uri = "link to download the WFS layer" layer = QgsVectorLayer(uri, "WFS_Layer", "WFS") QgsMapLayerRegistry.instance().addMapLayer(layer) But i ...
0
votes
0answers
74 views

QGIS 2.8/.10/…crashes when I run, into PyQGis Console, a script within “exit command” of any GUI designed with the same pyQgis script code…Why?

I use QGis 2.8 or 2.10. I open Console PyQGis, so I can write Python specific code that I can design any GUI, as a simple Window Form. After I wrote this code I run this script created and it's ok ...
1
vote
1answer
86 views

Applying single-band color map from file using pyQGIS?

I am importing a number of rasters using the python console in QGIS 2.8. I would like to color them all using the same color map, which I have saved to a file. I would like to do this using python so ...
1
vote
2answers
125 views

Python script for select by attribute function for QGIS

The following is of course working, selects these features of my_layer that have attribute 1 for my_field2 and appends the corresponding attributes of my_field1 in my_list: my_layer = ...
1
vote
1answer
260 views

How to run Refactor Fields algorithm in Python console?

I noticed that the Processing algorithm, Refactor Fields has a fields mapping parameter. I don't think I've come across this and definitely not used it before from the Python Console. It provides an ...
2
votes
2answers
82 views

Pyqgis load QML style from plugin

I need to apply a .qml style to a layer on my map as part of a Python plugin. I gather that this can be done via QgsMapLayer.loadNamedStyle(). The problem I have is that my .qml file is stored within ...
1
vote
0answers
47 views

Check for whole number in case statement

In an elevation file I want to find all the 5m contours and mark a column up as major. This has to be done in QGIS in the field calculator or modeler. I want to do something like the following based ...
2
votes
1answer
87 views

Use table manager in modeler in qgis

I need to reorder the fields in a tab file from within QGIS modeler. Table Manager plugin allows this but I can't seem to find a way to do this in modeler. It needs to be run on thousands of files. ...
2
votes
1answer
96 views

Adding multiple plugins to custom menu in QGIS

I am new to Python and QGIS and attempting to create some plugins to replicate in-house tools used in other GIS programs. I have added a custom menu using Python and added the plugin to the menu using ...
3
votes
1answer
90 views

How to merge layers into a single QgsVectorLayer?

I have a set of different layers (and their respective shapefiles) with information of electric lines. All the layers have the same Fields in their Attribute Tables, but contain information about ...
3
votes
2answers
79 views

Joining points to nearest line using pyQGIS?

I followed this suggestion to join points to nearest lines in QGIS. While most points get attached there are instances of points, often in close proximity to a line, that do not get connected (see ...
1
vote
0answers
122 views

python script in QGis - help using gdal.Polygonize

I want to create a very simple script in python that polygonizes a raster. Based on python cookbook + forums search I wrote the following code #import des modules from osgeo import gdal, ogr from ...
1
vote
1answer
29 views

Get values from metatada.txt

Is there a built in function in PyQGIS to import the values from a plugin's metadata.txt? I am developing a plugin and want to show the version corresponding to the value from metadata.txt. Is there ...
2
votes
1answer
127 views

Using processing.runalg in python script

I'm trying to run the following python script: from qgis.core import * import sys import os import qgis.utils from qgis.analysis import * app = QgsApplication([],True,"") # supply path to where is ...
3
votes
0answers
59 views

PyQgis: Print Composer using input from several Spatialite-tables

How can I create PDFs out of QGIS using the Print Composer Templates that include a lot of text (from a text-template) and within the text several information comes out of my spatiallite-database. A ...
7
votes
1answer
88 views

How to index large VRT files in QGIS?

I have a large number of small tiles merged into a single VRT. The rasters are only viewed at large scale, so only a few of them are visible at the same time. The map refresh in qgis is slowing down ...
1
vote
0answers
44 views

Getting started with PyQGIS [duplicate]

I'm trying to write a standalone python script to run some things I've already been able to run in the Python console. However, I'm having trouble running even the most simple application. I tried ...