Python bindings for QGIS.

learn more… | top users | synonyms

0
votes
0answers
39 views

How to get the signal when the color changes in pyQGIS?

I would like to have the signal when the color of a vector layer is changed by the user. In the doc, there is a signal that seems to fit ...
2
votes
1answer
75 views

How to write a new layer to PostgreSQL from QGIS plugin

The PyQGIS cookbook states that QgsVectorFileWriter can write vector layers to any format supported by OGR: https://www.qgis.org/en/docs/pyqgis_developer_cookbook/vector.html#writing-vector-layers ...
0
votes
0answers
29 views

How to add field to postgres layer with PyQgis?

I'm fetching a posgtres layer with PyQgis and then I'm trying to add field with this: lyr.startEditing() lyr.addAttribute(QgsField("class", QVariant.Int)) But It is not adding the field and also ...
0
votes
0answers
24 views

Add feature to csv via PyQGIS

I'm using PyQgis 2.0.1. Is it possible to add feature to csv file? I've tried to do this as it's shown in CoockBook: if caps & QgsVectorDataProvider.AddFeatures: feat = QgsFeature() ...
0
votes
2answers
41 views

How to programmatically fill a datetime field with datetime.datetime.now() function

I have been trying to programmatically fill a datetime field using values coming from datetime.datetime.now() function. #I create the temp shp using a URI URI = ...
0
votes
0answers
27 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
43 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.
0
votes
0answers
46 views

PyQGIS + PostGis: FATAL: sorry, too many clients already

I searched for questions regarding this problem and hadn't find one. I'm developing a custom application with a map canvas to show some geographic information from a PostGis database. After some ...
2
votes
1answer
50 views

How to properly establish a PostgreSQL connection using QgsCredentials

I'm trying to establish a Postgres connection using QgsCredentials as described here: How to access user credentials in database connection? The only problem is that I cannot establish a working ...
4
votes
0answers
63 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 ...
0
votes
0answers
34 views

How to get the color of a vector layer in pyQGIS?

I have see this topic (How to change the color of a vector layer in pyQGIS?) but I'm looking for get the color not to change. How I can resolve my problem ? Thanks
2
votes
1answer
70 views

QGIS python - identify and highlight features programatically

In QGIS there is an option to select features of a selected layer using a "identify feature" tool. Then the feature get highlighted in a different color and attribute dialog is poping up. like that i ...
0
votes
0answers
53 views

How to programmatically set a rule-based renderer in QGIS?

These days im in a process of developing a plugin , which highlights/change color of set of features in a vector layer depending on some calculation. i found nice article about QGIS – Rule based ...
1
vote
2answers
72 views

How to get the file paths of the loaded layers in a QGIS plugin?

I am very new to GIS, QGIS and Python so please bear with me. I am using QGIS 2.0 and I would like to develop a QGIS plugin that would display the raster layers of the main window in order to allow ...
1
vote
2answers
184 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
79 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 ...
1
vote
0answers
55 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
40 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 ...
2
votes
0answers
155 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 ...
1
vote
1answer
48 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
35 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
25 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
38 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
132 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
1answer
167 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 ...
0
votes
0answers
17 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
149 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
78 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
156 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
49 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
47 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
110 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
77 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
253 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
89 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
183 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
33 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
62 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
159 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
164 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
76 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 ...
0
votes
0answers
72 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
217 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?
1
vote
1answer
72 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
70 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
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 ...
0
votes
0answers
101 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
82 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.
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. ...