Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
0answers
65 views

How can I modify layer order with the QGIS python API

Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it? I use an existing QGIS ...
4
votes
0answers
222 views

QGis Zonal Statistics Plugin NoData included in Calculations

I have been trying to use the QGIS zonal statistics plugin. My raster has a nodata value of -99999 and all other values are positive. After computing the mean zonal statistics there are a number of ...
2
votes
0answers
21 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
84 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
33 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
157 views

Writing Stand Alone PyQGIS Script - QGIS 2.0

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
2
votes
0answers
131 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
562 views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
2
votes
0answers
179 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
136 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
669 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
114 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
12 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
30 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
55 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
44 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
56 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) ...
1
vote
0answers
61 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
67 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. ...
1
vote
0answers
59 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
55 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
33 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
126 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
99 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
123 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
70 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
109 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
31 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
161 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
101 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
178 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
57 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
251 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
61 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
214 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
66 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
190 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
429 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 += ...
1
vote
0answers
199 views

QGIS Updating composer label text via python - problem with Item Properties panel

I am writing a plugin that replaces the text of a composer label based on its itemID. When I change the text of the label using: item.setText("Hello World") the label changes on the composer but ...
0
votes
0answers
12 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, ...
0
votes
0answers
9 views

pyqgis: AttributeError: 'QgsRasterLayer' object has no attribute 'drawingStyle'

qgis gurus. I have a question about pyqgis and hopefully I can get some advise here. I am following http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html. In python console after a raster ...
0
votes
0answers
28 views

Help with scripts for processing raster files with the raster calculator in QGIS

I am trying to process some raster files using python scripts in Qgis 2.20, and I have been having trouble finding any documentation on using raster calculator in scripts being run in the processing ...
0
votes
0answers
27 views

How to add the attributes of selected features to my new layer in pyqgis

I am trying to create a layer from the selected points coordinates. I am drawing a circle to the coordinate of selected points. I also need to add initial attributes of my selected features to my new ...
0
votes
0answers
14 views

Multiparts and Multigeometries: checking for multigeometries with PyQGIS?

I have been working with PyQGIS and writing a small script to check whether the layers I have in the MapCanvas have geometries of type "MultiXX" because I want to run the "Multipart to Singleparts" ...
0
votes
0answers
17 views

insertVertex giving false in pyQGIS

I have this code from my plugin which work in Qgis 1.8 and I am trying to make it work in 2.0. I want to insert a coordinate x and y into a polyline after the last entry. points = geom.asPolyline() ...
0
votes
0answers
10 views

Is there an equivalent of QgsMapToolIdentify in QGIS 1.8?

I'm using quantum gis 1.8 Lisbon, and I need to select a point that is on the map by mouse, to know their attributes. But I can not use the QgsMapToolIdentify function, that would show me another ...
0
votes
0answers
4 views

Query from plugin that shows result on Map and in Attribute Table

I'd like to create a plugin that performs a static (no user input required) query that, based on a condition, selects all the features on the map and displays these in the attribute table. I have the ...
0
votes
0answers
20 views

How can I reproject a layer in pyqgis?

I have a problem. I'm currently trying to get the extent of a vector layer in latitude and longitude coordinates in python. The layer is currently in EPSG:3857, so .fullExtent() is not returning what ...
0
votes
0answers
45 views

Issue blocking QGIS feature form dialog with Python

I'm not sure where I'm going wrong with this python logic for a custom form in QGIS 2.0.1. There are a few things required by the validation function: that index of combo boxes aren't 0 (first index ...
0
votes
0answers
31 views

Problem with QgsVectorFileWriter

I am trying to write a python script that when it is called it will take an .sqlite layer and save it as a GeoJSON layer. This will be used in a leaflet app but for now my problem is with this script. ...