Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
2answers
571 views

How to perform SQL queries and get results from QGIS python console?

I'm writing a python script using QGIS API. I have to get results from postgres database table. The table has geometry field and other non-geometry fields. I want to perform SQL queries on ...
1
vote
1answer
122 views

How to find the polygons bordering a feature programmatically with qgis?

Is there a way to calculate the neighbors of a polygon with pyqgis for every feature? For example, the selected polygons relative to the one in the center: I found this solution, but it's a year ...
2
votes
0answers
85 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) ...
0
votes
1answer
54 views

Halt QGIS on startup

I have a custom made login form in Python, which launches on QGIS startup. But before the user has a chance to enter the credentials, the program starts normally, bypassing the form. From then on the ...
4
votes
1answer
295 views

How to write scripts that can call on both Arcpy and PyQGIS?

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 ...
1
vote
1answer
88 views

How can I add grid lines to a print composition using pyqgis?

I'm writing a qgis plugin to create an image in the print composer of the current map. I can get the map rendered in the proper place with a frame of the right width, and I can get grid annotations ...
0
votes
1answer
43 views

How to add a vector layer in QGIS in python

Someone please can help me how to start with the library qgis ? At first, i'd like to know, by clicking in a button on my litle plugin that i created for QGIS how to add a vector layer with python ...
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
52 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
385 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
344 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
238 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
138 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
300 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
92 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
104 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
407 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
126 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
218 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
90 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
591 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
238 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
118 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
100 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
343 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
115 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
86 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
131 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
120 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
79 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
220 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
153 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
107 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
221 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
239 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
315 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
967 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
324 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
188 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
273 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
96 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?