Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
0answers
263 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 ...
3
votes
0answers
153 views

How to create a line layer which connects a point layer to a line layer?

In the map shown below, I have manually created the dummy lines (in green). Using python, and without using PostGIS or sextante, I would like to automate the creation of these dummy links between a ...
2
votes
0answers
45 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
60 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
103 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
60 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
81 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
76 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
162 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
786 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
134 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
5 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 ...
1
vote
0answers
61 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
37 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
30 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
37 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
38 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
44 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
48 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
29 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
75 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
53 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
66 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
20 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
98 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
85 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
66 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
61 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
49 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
182 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
112 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
146 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
81 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
146 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
34 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
191 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
118 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 ...
1
vote
0answers
229 views

How to write vector layer to csv file with geometry by PYTHON?

I use Python try to write vector layer file to csv file with this code QgsVectorFileWriter.writeAsVectorFormat(mylayer, r'c:\temp\xyz.csv', "utf-8", None, "CSV") It can export to xyz.csv but only ...
1
vote
0answers
58 views

How to delete a point with known coordinates in python?

I was wondering if there is a piece of code that does the opposite that setGeometry does and removes a point if there is one at x and y coordinates?
1
vote
0answers
272 views

DLL problem with PyQGIS

I am having problems with Python Shell importing the module "qgis.core". When I type "import qgis.core" the Shell ("idle.pyw") gives me this error: Traceback (most recent call last): File ...
1
vote
0answers
65 views

What is the proper way to do an automatic rollback of a vector layer edit?

I'm trying to rollback automatically the changes in features of a in-memory vector layer that don't meet certain criteria. The code I'm using for testing looks like this: ... def some_function() ...
1
vote
0answers
255 views

Qgis Plugin development with postgres data

can someone help me with initial developing on qgis plugin that displays postgres data table on a QTTableView or QTTableWidget? So far: I can connect to database using psycopg2 or using ...
1
vote
0answers
68 views

SVG markers with PyQGIS

How do you SVG-marker layers in PyQGIS? I'm importing a vector layer and want to display it with SVG-markers. It seems that QgsSvgMarkerSymbolLayerV2 does not exist in PyQGIS...
1
vote
0answers
206 views

no module named core

Hi I am trying to access and use QGIS modules/class/methods from IDLE on a mac. I have had the same problem as a few other people, and browsing the forums have tried to follow the advice they have ...
1
vote
0answers
505 views

How to change feature's geometry?

Hy, I'm creating my layer like this: crs = core.QgsCoordinateReferenceSystem(4326, core.QgsCoordinateReferenceSystem.EpsgCrsId) uri = "Polygon" uri += '?crs=' + crs.authid() uri += ...
0
votes
0answers
36 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 ...
0
votes
0answers
23 views

pyQGIS : Way in order to know modifications?

I 'm writing a pyqgis script. I succeed in accessing gis vector data (lists) from my remote server (thanks to urllib) . I succed in displaying geometries and attributs. 1/ Now, i would like manage ...
0
votes
0answers
60 views

QGIS 2.4: plugin changes map tool canvas click behavior from 2.0

I had created a plugin for QGIS 2.0 to add new features more easily. It involves changing extents and updating snapping options along with triggering the default actionAddFeature(). However, I've ...
0
votes
0answers
13 views

v.clean in QGIS Python console

I have tried to use v.clean and v.clean.advanced (by GRASS GIS) within a script in QGIS, and was not able. I followed instructions here:, but was not able to do so. I got message: "No module named ...