Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
65 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
26 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
15 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
158 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
52 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
0answers
34 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
62 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
221 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
100 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
84 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
41 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
51 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
155 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
39 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
31 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
36 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
39 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
35 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
75 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
44 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
91 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
40 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
37 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
100 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
79 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
33 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
88 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
72 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
19 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
42 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
47 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
94 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
98 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
52 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
44 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 ...
1
vote
1answer
68 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
57 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
66 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
58 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
71 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
25 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
56 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
49 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 ...
6
votes
0answers
58 views

QGIS: large .vrt indexing

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
43 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 ...
3
votes
1answer
35 views

Initialising QgsFeature with predefined field names using PyQGIS?

I need to create function that assembles QgsFeature from scratch: takes id, dictionary of attributes, and geometry as input. The issue is that feature that is being created doesn't belong to any layer ...
1
vote
0answers
27 views

WMS layer throws “IReadBlock failed at X offset 0, Y offset 1” error. Possible XML issues

I am working with a few WMS layers to try and see which one would work best with an application I'm developing out of QGIS 2.8. I need the CRS to be in EPSG 4326 but, as many of you know, most webmaps ...
1
vote
0answers
20 views

Should I set the projection if the data has already been projected?

I need to plot some data which was produced on a native grid with a lambert conformal conic projection. I need to create a geotiff (using python and gdal) and was wondering how to go about and do ...
1
vote
0answers
83 views

how to set the geotransform using GDAL in python

I am trying to create an image from a numpy array and georefenrece it so that I can import it into qgis. I have the latitude and longitude in degrees for the top left corner of the array as well as ...