Python bindings for QGIS.

learn more… | top users | synonyms

5
votes
0answers
406 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
61 views

Find Polygon in “Layer A” containing Polygon in “Layer B”

I haven't found yet someone with the same problem, so I'm posting a new question. The topic seems quite standard, so I'm sure there's a way to do it in QGIS. I have two layers: Region Layer Postcode ...
3
votes
0answers
68 views

Problem with performance when loading PostGIS layer using pyQGIS

I'm having a question on loading a PostGIS layer into the project from my QGIS plugin. The code is like this: uri1 = qgis.core.QgsDataSourceURI() uri1.setConnection(str(host), str(port), ...
3
votes
0answers
91 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
32 views

Using pdb in QGIS console

I am unable to use pdb from qgis console. If I run a function that calls pdb.set_trace() I get the error Traceback (most recent call last): File "<input>", line 1, in <module> File ...
2
votes
0answers
17 views

PyQGIS: Using a Simple Coordinate System (Cartesian Space)

Is there a built in non-world coordinate system that represents simple cartesian space? I want to use PyQGIS but have a canvas set with 0,0 origin and infinite planar space in each direction. In ...
2
votes
0answers
33 views

How to load all items from a template with pyQGIS in QGIS 2.6

Since QGIS 2.6, the LoadFromTemplate method seems not work any more (or works differently?) This is my code to add items in my composer from a template : self.composition = ...
2
votes
0answers
33 views

Add button to custom standalone QGIS application

Im able to implement zoom in and zoom out functionality as described in the PyQGIS developer cookbook using a tool bar. I would like to have buttons that display above my map canvas layer and have the ...
2
votes
0answers
65 views

PyQGIS cookbook seems out of date

I am trying to follow the http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/ but it seems to be out of date, for example many of the raster methods no longer work as indicated or even ...
2
votes
0answers
28 views

How to make added toolbar buttons exclusive?

I've added a toolbar to the QGIS mainWindow. Also I've added some checkable buttons to the toolbar. How can i now make my checkable buttons untoggle on QGIS default toolbars' checkable buttons press ...
2
votes
0answers
67 views

Iterating between two layers using QGIS python

I will try and explain my situation as clearly as possible. I just created my first plugin that is being used to analyze between various layers and give back quantities to the user. Most of it is ...
2
votes
0answers
36 views

Assigning Color Ramp using PyQGIS

According to the PyQGIS Cookbook, a color ramp can be assigned in the following way: rlayer.setColorShadingAlgorithm(QgsRasterLayer.ColorRampShader) lst = [ QgsColorRampShader.ColorRampItem(0, ...
2
votes
0answers
62 views

How to get user and password of a PostGIS layer

I wonder if it is possible to get the user and password for a PostGIS database if they are stored in the PostGis connection information. I get the connection information at the moment from the ...
2
votes
0answers
47 views

How setup python path in my ide to recognize QGIS API

I'm using Intellij with python plugin. Classpath for python contains $QGIS/apps/qgis/python but my ide not recognize eg. QgsVectorLayer. Any additional entry is required?
2
votes
0answers
21 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
39 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
35 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
52 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
49 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 ...
2
votes
0answers
48 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
97 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 ...
2
votes
0answers
69 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 ...
2
votes
0answers
125 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
90 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
110 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
86 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
210 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
243 views

PyQGIS joining a dbf to a shapefile

I am trying to join a shp and dbf file using the PyQGIS API. The code I'll use is below: from PyQt4.QtCore import * vector1 = QgsVectorLayer("path to dbf file", "test1", "ogr") id1 = vector1.id() ...
2
votes
0answers
153 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
16 views

How to show combine results or export them with PyQgis

I'm quite new in Pyqgis and i think Pyqgis could make my work easier. I first want to try with a simple code, here is what i want: merge some features and then export them in a shape files. For the ...
1
vote
0answers
32 views

Why must I write `geometryType() == 3` for point and polygon shapefiles?

I am asking this question based on the result I received from this earlier post. The following script only works if I set geometryType() == 3 as that is what is being printed out in the Python console ...
1
vote
0answers
29 views

PyQGIS: standard and advanced linear referencing possibilities

I'm aware of the existence of the following QGIS plugins: QChainage Event layer linear referencing LRS Although, all of these tools offer some linear referencing capabilities, I find that they ...
1
vote
0answers
28 views

How to exit the QDialogBox button in qgis using python programming

I have created a dialog box with ok and cancel buttons.But i want one more exit button where it has to exit the QdialogBox. When i am using exit()it is exiting the complete qgis but i want to exit ...
1
vote
0answers
24 views

How to get the last edited feature id using python

After merging the two features in the polygon the feature id will be changed for the merged feature after committing the changes. So how do i get the feature id of the merged feature or the last ...
1
vote
0answers
26 views

How to open a second window in QGIS plugin from a button inside the main window

If I already created a qgis plugin, and i need to create a button inside that plugin that opens a new window, how is that possible? Qt creator won't add a slot unless there are a header file. I looked ...
1
vote
0answers
69 views

How to overlay Google Map in a standalone PyQgis application?

I have created a standalone PyQGIS app (within Python itself, not a plugin) with PyQt and PyQGIS API. It generates my map really well. I would like to overlay a Google Map layer as base map just like ...
1
vote
0answers
80 views

Apply graduated symbology renderer works in Python console but not in standalone script

I use the following PyQGIS script to load a vector layer from a shapefile and apply graduated symbology to it (tried to make it as minimalistic as possible). This works well in the QGIS 2.4 Chugiak ...
1
vote
0answers
37 views

Highlight the selected feature with different colors

Is it possible to change the color of a selected feature in qgis 2.2.0 Valmiera? To highlight a feature I use: aLayer.Select(feat.id()) box = vlayer.boundingBoxOfSelected() ...
1
vote
0answers
48 views

Error Loading Layer/Shapefile in a Standalone Python QGis Application

I tried loading a shapefile on Python using PyQgis API but to no avail. I double-checked the path to shapefile and found it to be correct. QGIS module also seems to be imported just fine. When I ...
1
vote
0answers
35 views

Arcpy and pyqgis on same IDE

I have question: is it possible to set up arcpy and pyqgis on the same IDE (I use Pycharm). I have some problem with running my pyqgis scripts from pycharm. When I first configure Pycharm to recognize ...
1
vote
0answers
57 views

PyQGIS add WMS layer with CQL_FILTER

Dear PyQgis developers! I'd like to add a wms layer through my QGIS plugin with custom CQL_FILTER parameters. My problem is, that the CQL_FILTER parameters are not passed to the GeoServer (I can see ...
1
vote
0answers
64 views

How to change color ramp in graduated classification with standard deviation using pyqgis

I'm using graduated clasiffication with standard deviation to style my shapefile (see code below). But I need to use different color ramp for classes below mean (-1std, -2std etc.).I'm thinking of ...
1
vote
0answers
78 views

QGIS Add WMS layer with python

I'm developing a stand alone python script using QGIS 2.2.0 libraries. I want to add a WMS base layer to my map, and I follow the instructions reported by the documentation: urlWithParams = ...
1
vote
0answers
28 views

PyQGIS: Properly trigger actionPan() tool when feature is added

I wrote a plugin which creates a custom map tool that adds features. I would like to cleanly connect to the pan tool after a feature is added. I've done it in the following way and it works, but I get ...
1
vote
0answers
57 views

QGIS processing framework SAGA NaturalNeighbor in external Python Script - No Output

I want to build a little script, which generates a NaturalNeighbor grid based on a point Shapefile. The script runs within my PyDev environment without any error messages, but no outputfile is ...
1
vote
0answers
33 views

Create “grid” of polygons with the same 3D area based on an underlying raster variable (e.g. DTM height)

This could apply to point or raster values but imagine a raster of a continuous variable such as height (DTM). Is there a way to create a complete coverage of polygons that will have an equal area, ...
1
vote
0answers
29 views

Pyqgis, Plugin development issues

I am new in the pyqgis world... I am trying to adapt the Geocoding Plugin developed by Alessandro Pasotti to a new plugin. I have been dealing with the following issues and I think you have the ...
1
vote
0answers
39 views

ERROR 6: EPSG PCS/GCS code error when running QgsGeometryAnalyzer().buffer

I am trying to buffer points from a FileGDB in a PyQGIS script. I setup my environment with the following batch file and run the python script below. The problem is that I get ERROR 6: EPSG ...
1
vote
0answers
296 views

Ubuntu 14.04 Another ImportError: No module named qgis.core

Issue I feel like this is covered territory here, but the issue is has appeared on two separate occasions for me--first when upgrading from Ubuntu 12.04 to 14.04 in May. I got it fixed then, but I ...
1
vote
0answers
41 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. ...