Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
1answer
35 views

How to randomly select from existing points within each polygon?

I have a polygon layer (where each feature has a class attribute), and a point layer, and there are at least 10 points within each feature of the polygon. Is there a way to randomly select only "k" ...
1
vote
1answer
48 views

PyQGIS 2.0 API problem reading attributes

Im reading some attributes from shapefile features in a loop. According to this: http://nathanw.net/2013/06/13/new-qgis-20-api/ I should be able to reference my attributes (and getting native python ...
1
vote
1answer
365 views

QGis 2.0.1 mapserver extension missing

I tried to export my Qgis projects to mapserver, using RT mapserver extension, because there is not any other extension in my version of QGis.(QGis 2.0.1 Dufour on ubuntu 12.04 LTS). After installing ...
3
votes
2answers
341 views

Rendering and Labeling Shapefile with PyQGIS

I've been running into a few problems working with the QGIS API for python. I've gotten more comfortable working in the python console in QGIS but I run into problems when I try to run the code ...
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 ...
4
votes
2answers
232 views

Using Python and open source modules, how can I perform Raster Calculator functions?

I would like to perform mathematical functions similar to those you would use Raster Calculator for in ArcMap, however I'd like to do it in Python without using the Arcpy module. I have the osgeo ...
2
votes
1answer
136 views

QGIS 2.0 Plugin: Select and Identify a Single Feature

given is a layer with some nodes on it and every node has some attributes(name, id, etc...). For showing up the informations of a single node I can use the "Identify Feature Tool". Choose the tool, ...
0
votes
0answers
297 views

On install “Couldn't load SIP module.” - should I reroute Python config or download sip?

(Please note I'm still relatively new to Linux). When I run QGIS after install I get a message 'Could't load SIP module'. I've looked for help and am conflicting advice on what my next step should ...
1
vote
1answer
90 views

How to programmatically add an algorithm from external plugin to QGIS processing toolbox?

I'm writing a python plugin for QGIS and I'd like to know if it's possible to provide an interface to it from the processing toolbox. I can see how the existing algorithms are loaded into processing ...
0
votes
0answers
76 views

Missing pyexpat on QGIS 2.0.1: pyuic4 fails

I have encountered a problem when trying to develop a custom plugin for QGIS 2.0.1 (Python 2.7.5 with two additional Python installations on the same machine). When I try to compile the UI file ...
0
votes
0answers
7 views

Apply styles to the attribute window

Is there anyway of "hijacking" the attribute window for full control in Python. I would like to apply the map style to the attribute window also. If the geometry is red, the cell background of ...
2
votes
1answer
129 views

Why does writing large shapefiles crash QGIS?

I'm trying to write large shapefiles with QGIS 2.0 API, using Python, which crashes QGIS. The data is composed of simple two point lines and a data table of five columns. A thousand features or so ...
2
votes
2answers
103 views

How can I close the identify result dialog programmatically?

I am trying to close the identify result dialog which appeared when I select to identify a feature from the active layer. Does someone know how can I do it?
1
vote
1answer
401 views

QGIS 2.0 Python API: Layer vector style loaded from file, marker symbology is respected, labels are not

Im loading a QgsVectorLayer and showing it on map. I load the style i prepared with desktop QGIS 2.0.1 using the layer.loadNamedStyles(path) function in the API and it seems to work, kind of, because ...
2
votes
2answers
125 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
3
votes
1answer
217 views

How to apply a color gradient to a shapefile from QGIS console?

Anyone knows how to do a color gradient from the console to a shape file in Qgis (orin Python)? Like the image below.
3
votes
1answer
39 views

How to store the CHANGES to a map database

I'm looking into providing a map amendment service for a particular map series. The service will help map owners look into the changes made to the operational features of the map, after the map was ...
0
votes
0answers
89 views

QgsMapCanvas displays layer only after i resize the window

Im medlling with a standalone PyQGis application (based on 2.0.1). I have no problems with the setup, however when i set up my layers as stated in the docs: layer = QgsVectorLayer(path, name, ...
0
votes
1answer
568 views

How to set PYTHONPATH in OS X to use PyQGIS?

I am trying to use PyQGIS in custom applications. I am on Mac OS X 10.9 with QGIS 2.0.1-Dufour. I know I have to set the the PYTHONPATH environment variable. This is the path to QGIS on OS X: ...
0
votes
2answers
237 views

Developing standalone gis applications using pyqgis

I am trying to develop a standalone application using pyqgis but I have no clue on where to start and where to write the code to make it happen so if anyone can provide me a tutorial to getting ...
2
votes
1answer
114 views

How do I access QGIS program settings programmatically?

I am trying to temporarily enable the option in QGIS using PyQt4 to suppress the attribute dialog popup after a feature is added. I found an example in the cookbook but it doesn't indicate how to get ...
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. ...
3
votes
1answer
338 views

How to generate a grid programmatically in Python without GUI?

Is there a QGIS Python binding for generating a grid programmatically without using the GUI?
2
votes
1answer
114 views

How to show in a custom QGIS form the feature and/or geometry info?

I need to show point coordinates on the from dialog used to edit the attributes of a point.. I see that in the formOpen the dialog receives a layerId and a featureId, but no iface object, so how can ...
1
vote
1answer
89 views

Irrational feature ID behavior in a PyQgis script

I've written a script to determine the coordinates of a point shapefile and insert them into its attribute table. It works perfectly when the ID sequence of the indiviual features begins with 0, yet ...
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 ...
0
votes
0answers
129 views

Calculating area with python qgis

I am a little stumped with determining the area of polygons in the python console. I want the output to be in meters^2, so using: qgis.utils.iface.mapCanvas().setMapUnits(0) ...
1
vote
2answers
118 views

How to Project a point on feature in PyQgis?

In Arcgis IProximityOperator.QueryNearestPoint Method was available to get the nearest point. Similarly Is there any function available in pyQgis? Thanks in Advance.
2
votes
0answers
77 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
3answers
219 views

How to access user credentials in database connection?

I am trying to automate a couple of things when a QGIS plugin is activated: If Layer A is not in the TOC, add it. This requests username and password to access a PostGIS table using the inbuilt ...
2
votes
1answer
152 views

Which data providers support loading attribute tables without geometry?

I have a table in Memory from a cx_Oracle query (a list of rows, and a list of field names and their types) in my python plugin and I want to load it as a geometry-less layer (Attribute table) in ...
0
votes
0answers
105 views

Unable to render layers in MapCanvas using PyQGIS/PyQt4

I am trying to get some layers into a MapCanvas and style them. I am following the PyQgis Cookbook info here but my code is just not working. I've been spinning my wheels on this for over a week now ...
0
votes
1answer
217 views

Unable to load PostGIS vector layer into QGIS using python cookbook recipe

I'm having trouble loading a PostGIS layer using Dufour (from osgeo4w), using the guide at http://www.qgis.org/en/docs/pyqgis_developer_cookbook/loadlayer.html. I just get the 'invalid layer' message. ...
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: >>> ...
2
votes
1answer
233 views

How to label vector features programmatically?

I am using python for QGIS 2.0.1 and I have a vector layer of points representing the positions of state labels. I want to display the 'state abbreviation' attribute on the corresponding point for ...
1
vote
2answers
311 views

Programmatically load composer from template and generate atlas using pyQgis

I Am trying to build a plugin to load a print composer from file, generate an atlas and export to image. So far I have been successful in loading the template and exporting it to image. I have been ...
3
votes
2answers
953 views

Standalone applications using QGIS and environment variables

I've tried going through IRC to see if people can help me out with this, but the medium seems a little clumsy for making any answers clear, so I'm going to try this instead. I would like to program a ...
4
votes
2answers
321 views

How do I set layer transparency in QGIS 2.0 with Python?

I have a raster layer loaded in QGIS and I'd like to be able to set its transparency via the Python console. I'm new to the API and have not been able to find out how to do this. Any help would be ...
10
votes
1answer
307 views

PyQGIS file lock release

I was wondering what triggers the release of file locks in pyQGIS? I am trying to delete a few data sources (used temporarily) by calling QgsVectorFileWriter.deleteShapeFile, but I have to quit QGIS ...
2
votes
1answer
185 views

How to create a symbol with graduated marker size and line width in pyQGIS?

I am using QGIS + pyQGIS + Python. Layer geometry is line. Each line has a magnitude and a direction (from 1st node to 2nd node). What exactly I want to perform is "graduated width marker symbology ...
0
votes
1answer
262 views

How to zoom to the extent of Qgsvectolayer qgis?

Anyone know how to zoom to the extent of a Vectorlayer in qgis using python plugin?
0
votes
0answers
94 views

how can i read an attribute value from qgsfeature?

How can i read an attribute value from qgsfeature ? i am trying to update some attribute using other and i have to read value from attribute in the qgsfeature . my source code: provider = ...
0
votes
0answers
41 views

What is the action name in qgsinterface for the deselect feature from all the layer tool?

I want to add the deselect feature from all the layer tool in the toolbar when the qgis user start editing a vector layer. anyone know what is the name of this action in qgis api 1.8?
1
vote
1answer
229 views

How to activate a layer in QGIS layers legend

How can I activate a layer in qgis map legend automatically using python code . I am using qgis.utils.iface.setActiveLayer(self.theLayerToEdit) but the layer is still not checked in the maplegend. ...
2
votes
2answers
352 views

How to load memory output from QGIS processing?

Many processing algorithms have an option to save output as memory. If ran from toolbox, this works fine, because you can tick the "Open output file after running algorithm" box. Looking at the ...
3
votes
2answers
492 views

How to get field names in pyqgis 2.0

I am trying to change an plugin from QGIS 1.8 to 2.0. In the 1.8 version I create a table of the field names like this: layer = vlayer provider = layer.dataProvider() feat = QGSFeatrue() allAttrs = ...
0
votes
1answer
93 views

Different output from running algorithm in toolbox and from script

I am unable to get the same results when running the qgis:reproject tool from QGIS processing toolbox (QGIS version 2.0.1) as when running it from a Python script (console). In this example I am ...
1
vote
2answers
149 views

No prj file output from qgis:reproject

I'm trying to reproject a vector layer using the 'qgis:reproject' algorithm in the processing/sextante module of QGIS, from Python. This kind of works, but the .prj and .qpj files created after ...
2
votes
1answer
451 views

Using in-memory vector layer with QGIS processing / SEXTANTE

I'm trying to run the qgis:clip algorithm from console, but am getting an error when using an in-memory layer as the overlay parameter. Is this to be expected, or am I doing something wrong? Code: ...
1
vote
1answer
212 views

Select by SQL in QGIS Python

In the GUI there is the Query Builder, but that does not seem to be easily available in Python. The processing (SEXTANTE) module has the qgis:selectbyattribute algorithm, but that only supports ...