Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
0answers
295 views

PyQGIS CRS on the fly reprojetion

As a first step of a pyqgis plugin I'm trying to import several shape files at once. To get them aligned, using the GUI, I'd enable on the fly reprojections and set the project crs to WGS84. I'd then ...
2
votes
0answers
30 views

Performing buffering and intersection with script in PyQGIS

I wrote a script that performs the intersection of two layers: The first Layer -> layer1, represents the rivers The second Layer -> layer2, represents a set of circular dots distributed in a ...
2
votes
0answers
19 views

Refreshing “layer render order” widget

i made changes in the render order of my map canvas using a : qgis.utils.iface.mapCanvas().setLayerSet(a) "a" being a list of QgsMapCanvasLayer My code is working as expected (i see result on map ...
2
votes
0answers
24 views

Memory layer or QgsVectorFileWriter Error?

Currently this excerpt of code will not save to file (as it is supposed to). The memory layer is visable and editable. Yet even when manually saving the layer, any priorly added features ...
2
votes
0answers
20 views

access point layer representation in qgis with pyqgis

I am exporting the style of a categorized point layer with qgis: unfortunately my code only extract the size of the symbol in the definition of the properties of the layer but not the ...
2
votes
0answers
39 views

How to add a TIF raster layer programmatically?

This is my code whenever i try to load .tif image it shows layer is not valid,QgsRasterLayer always return invalid layer (I am using linux 12.04). QString myFileName = ...
2
votes
0answers
28 views

Add a new polygon to an existing shapefile from wkt in QGIS

I have a layer of polygons in QGIS; I want to add programatically (pyqgis) a new polygon to this layer using WKT. Example: mywkt = POLYGON ((522762 376413 0,530635 368671 0,522237 353713 0,522762 ...
2
votes
0answers
60 views

order layer in QGIS with pyqgis

I´m new in pyqgis. I´m looking for a code to move one layer in TOC to a specific position. Is it possible? Thanks a lot!
2
votes
0answers
76 views

Programmatically change layer position in the table of contents (QGIS)

I am trying move/position a layer to the bottom of the TOC by using addTopLevelItem on all other layers. I unsure how to reference the layers as QTreeWidgetItem's. def bg_bottom_level_item(self): ...
2
votes
0answers
110 views

How to eliminate gaps and overlaps in a layer of SpatiaLite table?

I'm try to snap all polygons in a table to remove gaps and overlaps. I can remove gaps but get new overlaps. I have no idea what doing wrong... sorry, I'm new in SpatiaLite. I tried the following: ...
2
votes
0answers
70 views

How to open QGIS attribute table in form view using Python?

I've got a plugin where I load some layers. On the last layer loaded I show the attribute table. I would like to select the view different from the table view (see image). How can I do this in Python? ...
2
votes
0answers
91 views

How can i add a north arrow in QgsComposition?

I'm trying to add an svg image of north arrow in QgsComposition using this code: mapRenderer = iface.mapCanvas().mapRenderer() theComposition = QgsComposition(mapRenderer) ...
2
votes
0answers
80 views

Is there a way to build topology and work with topology relations in PyQGIS?

Is there a way to build topology and work with topology relations in PyQGIS? I'm asking because I need to run some custom generalization algorithms on my data, and I need to preserve topology. ...
2
votes
0answers
178 views

How to render a transparent raster layer on top of one or more vector layers with PyQgis?

I been trying to render a map with a 3 vector layers and one raster layer. The idea is that the raster layer should be on top of the other 3 vector layers. The problem is that even when I add the ...
2
votes
0answers
832 views

legend groups and layer position/order qgis 1.8

I'm tring to programmatically create layer sequence also using groups. Simple python code: layer = QgsVectorLayer("004cp000.shp", "004cp000", "ogr") QgsMapLayerRegistry.instance().addMapLayer(layer) ...
2
votes
0answers
137 views

Setting border-style to 'no pen' using QgsGraduatedSymbolRendererV2

I am developing a QGIS plugin that, after a series of inputs, will produce a thematic map using the QgsGraduatedSymbolRendererV2. Because the polygon are very small, the boarders make it such that ...
1
vote
0answers
28 views

Clipping between features within a single vector?

Is it possible (via the Qgis API and friends), to clip polygonal features within a single vector layer? The hope is to accomplish this without having to duplicate the feature into a new layer. ...
1
vote
0answers
34 views

Using two different Python versions for QGIS scripting?

I´m intending to learn scripting with python in QGIS, but I have a couple of questions. I'm using Python 3.4 for learning which is installed in my laptop, but QGIS is using Python2.7 How could I ...
1
vote
0answers
29 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
19 views

PyQGIS standalone gdal_ECW_JP2ECW.dll error

This is my code in a batch file My error messages are gdal_ECW_JP2ECW.dll error unable to open EPSG support file gcs.csv Thanks in advance REM Change OSGEO4W_ROOT to point to the base install folder ...
1
vote
0answers
34 views

Modifying properties of Attributes Table in QGIS?

In my QGIS project I'm using vector layers that require a lot of data inputting/editing. The problem is that some of the data I'm inputting varies greatly in matter of length and structure (various ...
1
vote
0answers
39 views

PyQGIS: Editable Combobox for Value Map widget isses

I am having issues with an editable combo box in QGIS 2.4. The edit widget is set to Value Map with an uploaded CSV. However, if a new values (not included in the key value pair list) is added, the ...
1
vote
0answers
46 views

developer problem with PyQGIS

I am a QGIS developer. We have been modifying the source code of QGIS for several months and have done good work in QGIS version 2.1. After that we tried to do the same modifications for QGIS version ...
1
vote
0answers
32 views

QGIS - Calling interpolation extension from python console

I would like to call the QGIS interpolation extension function (TIN method) (Raster->Interpolate) from python console. I can't find the corresponding function within QGIS API or within the ...
1
vote
0answers
84 views

Using qgis modules in standalone application with PySide?

I want to make small standalone application using PySide and QGIS python modules to display satellite images and do standard GIS operations, like creating new shape file and placing polygons or points ...
1
vote
0answers
74 views

QVariant is not defined when using addAttributes

When I try to add a field programmatically with the following code: import os.path from PyQt4 import QtGui, QtCore legend = qgis.utils.iface.legendInterface() allLayers = legend.layers() for i in ...
1
vote
0answers
36 views

QGIS python plugin: PyQGIS for spatial join

For a QGIS 2.0 and 2.2 Python plugin, I am trying to update one layer's field attribute with another layer's field attribute based on geometry function QgsGeometry.within(). My first layer is a point ...
1
vote
0answers
76 views

PyQGIS: How to color raster layer with existing colorBrewerMap

With pyqgis I have added multiple new raster layers to the legendinterface(). Because i like the ColorBrewer style i want to color some of them with the "Spectral" gradient. How can I do this in ...
1
vote
0answers
39 views

How to include external libraries with my QGIS plugin?

I'm developing a plugin which makes use of "networkx" library extensively. However, networkx is not part of Python libraries pre-installed in QGIS. Is there a way to include this library with my ...
1
vote
0answers
52 views

Programmatically selecting features by polygon

Expanding upon this post how could you use QGis to programmatically draw a selection polygon and select features within the polygon? I have been using QgsMapToolEmitPoint(self.canvas), to find and ...
1
vote
0answers
53 views

Programmatically modify layer datasource on project save event (QGIS)

I have a QGIS plugin which allows users to add WFS/WMS layers to the map. I would like to be able to scramble the user ID part (token) of the uri when the project is saved/closed and then use my own ...
1
vote
0answers
31 views

can not delete file after using runalg function

I my plugin I use the runalg function: processing.runalg("qgis:clip",filepath + "/temp2.shp", Layer, filepath + '/' + layerName) vlayer = QgsVectorLayer(filepath + '/' + layerName + '.shp',layerName, ...
1
vote
0answers
36 views

Using pyqgis with existing ArcGIS files

I'm pretty new to GIS. I have some files that seem to have been created using ArcGIS (I got them from here http://www.fao.org/ag/againfo/resources/en/glw/GLW_dens.html). I would like to do some ...
1
vote
0answers
78 views

How to fetch openlayers layers from pyqgis?

My objective is to fetch maps provided by openLayers, as in openLayers_plugin, from a stand alone python script. I would like to get it superposed to my shp file. As can be read on ...
1
vote
0answers
61 views

How to apply categorized symbols to polygon layer with PyQgis?

I'm fetching a polygon layer from postgres like this: uri = QgsDataSourceURI() uri.setConnection("localhost", "5432", "mydb", "postgres", "xxx") uri.setDataSource("public", "my_table", "geom") lyr = ...
1
vote
0answers
75 views

Install PyQGIS in virtualenv

Is it possible to install PyQGIS in virtual environment? I want to use rendering capabilities in my own application which runs using virtualenv.
1
vote
0answers
21 views

MSHP file from SAGA tough to delete

After running a SAGA line dissolve process in QGIS, an MSHP file is created (amongst other things). Fine by me, though I'm not sure what it's used for (metadata in XML format?). Problem is that it ...
1
vote
0answers
105 views

Display plugin icon

I'm unable to setup the display of the toolbar icon for a plugin in QGIS 2.0. I have compiled the "resources.qrc" with the correct path and filename, and checked possible spelling errors in the code. ...
1
vote
0answers
87 views

Workflow Scripting in QGIS

I have created a hexagonal grid shapefile using MMQGIS and want to use this for hexagonal binning. I have another point shapefile which contains patient records for three different types of hospital ...
1
vote
0answers
72 views

How can I change the NoData value in QGIS 2.x using the python console

I'm trying to add a NoData value to a single band raster image in QGIS 2.0 using the python console but can't find the right bit of code to do it. Here's what I see on the console: >>> ...
1
vote
0answers
63 views

PyQGIS - Converting WKB to String

Using PyQGIS, i'd like to print the string representation of a point WKB (like what PostGIS displays in geometry columns). For example: p = QgsGeometry.fromPoint(QgsPoint(2, 4)) wkb = p.asWkb() print ...
1
vote
0answers
53 views

How to calculate an expression for a field using PyQgis?

I'm beginner user of PyQGIS. I would like to create one button to calculate one expression for example the relative frequencies for each field. How can i do it? Thanks for your help. Best regards. ...
1
vote
0answers
198 views

Unable to use pyQGiS in a custom application - import arcgis.core error

I'm using windows 7 and/or 8 64 bit with QGiS 2.01. I'm wanting to us the pyQGiS tools in a custom python application outside of the QGiS environment (i.e by running a python executable located in ...
1
vote
0answers
117 views

Different result featureCount() on QgsVectorLayer QGIS 1.8 vs QGIS 2.0?

I use the following code in a layer action: <uri definition etc> sql = 'id = "[% "id" %]"'; uri.setSql(sql); layername = 'TableName [% "id" %]'; vlayer = ...
1
vote
0answers
161 views

How to change the color of a selected feature with pyQGIS?

is it possible to change the color of a selected feature in qgis 1.8? To highlight a feature I use: vlayer.setSelectedFeatures(selectedList) box = vlayer.boundingBoxOfSelected() ...
1
vote
0answers
84 views

How to join attributes by location with command line

I would like to joint the attributes of 2 shapefiles by location but with a command line (linux). This feature is easy in QGIS but it is VERY slow. Is there a way of doing this with ogr or pyqgis ? ...
1
vote
0answers
161 views

Loading Vector Layer PyQGIS Issues

I am trying to follow PYQGIS documentation for loading a shapefile from inside a script. http://www.qgis.org/pyqgis-cookbook/intro.html I was able to set the datasource and run the QgsVectorLayer ...
1
vote
0answers
36 views

Can I use the PyQgis QgisPluginLayer to create heatmaps?

I am working in an application to generate maps from a bunch of MIF/MID files, I already created almost all the maps that I need, but, now I want to create heatmaps. I can't find any way of creating ...
1
vote
0answers
202 views

How to load the default layer style from Postgresql with Python?

I would like to write a python macro that upon opening my QGIS project file will reload the default style for each layer from the postgres 'layer_style' table. I have had a look at the documentation ...
1
vote
0answers
128 views

Spatial Filter in Qgis Using Python

Is it possible to create buffer and get intersected features in Qgis using Python? I did in ArcObjects.but i need the same in QGIS also. Dim topo As ITopologicalOperator topo = chkPoint Dim sFc As ...