Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
7 views

How to find if map layer registry is empty?

In my script I want to open layer named my_layer if it is in the map layer registry. I use following code for it: inputLayer = QgsMapLayerRegistry.instance().mapLayersByName("my_layer")[0] If not ...
2
votes
0answers
10 views

PyQgis: How to access a deleted features attributes (before committing)

I have a signal setup for a feature deletion event on a layer: self.layer.featureDeleted.connect(self.feature_deleted) When I try and grab an attribute from the deleted feature on the slot, a ...
1
vote
1answer
11 views

Polygons in one layer have different attributes

Is it possible in PyQGIS to have in one layer more polygons and some would have one set of attributes and another different? E.g. Polygon_1(name, size, average_age), Polygon_2(name, size, ...
2
votes
0answers
18 views

QGIS.How to load a style from POSTGIS in PyQt

The thing is that I have four styles I have created in QGIS trough the GUI and saved into a postgresql database. I can see them in the table named layer_styles I have seen similar questions asking ...
2
votes
1answer
353 views

How to begin with tool development for GRASS gis or QGIS GRASS

I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...
2
votes
1answer
15 views

How can I create a QGIS plugin that needs an external Python library?

I’m trying to enhance QGIS's Profiletool plugin by adding DXF export functionnality. For this, I need to to import dxfwrite library. As it's installed on my computer, i added the following lines to ...
1
vote
2answers
20 views

How to put a frame around a legend using QgsComposerLegend?

I can already see this being a simple answer but I'm stumped with this. I want to create a frame around a legend created by a PyQGIS script Code snippet is: legend = QgsComposerLegend(c) ...
2
votes
2answers
3k views

How to access attribute data type in QGIS?

I've been developing a plugin on QGIS platform using PyQGIS. So far plugin does the following: You can select any feature of the already loaded vector layer in QGIS. After selection, plugin displays ...
2
votes
1answer
24 views

QGIS: Finding electric network loops

With QGIS, how can we analyse an electrical network to find loops? Using Python is not a problem, however there is not a solution in the QGIS Python API. The QgsGraphAnalyzer has dijkstra and ...
2
votes
0answers
27 views

How to rename field names in a shapefile attribute table without table manager using python

By using the table manager we can rename the field names but i want to rename of fields using python. How can i do that?
1
vote
1answer
15 views

How to read non-spatial data using PyQgis?

I'm generating maps with QGis. What I do is generate a bunch of non-spatial data on a set of cities (using VBA), and still using VBA, generate a python code that will automaticaly output general map ...
1
vote
2answers
46 views

How to create a polygon grid with un-even spacing between research plots?

I have an orthomosaic of a crop field with small research plots (3.8 X 1.44 m and 0.22m b/w plots and 0.50m b/w range spacing). I would like to create a polygon layer using this information. After ...
2
votes
1answer
41 views

How to place labels at the boundary of the current map extent

I have a layer of reference grid lines on top of several map layers. The grid lines should be labeled with coordinate values: vertical grid lines with x-values and horizontal lines with y-values. The ...
0
votes
0answers
8 views

Iteratively Change Object's Instance Attributes PyQGIS

I am trying to create new instance attributes (NOT feature attributes) for a collection of features in a vector layer in PyQGIS. I'm getting some weird results and am wondering if this is even ...
1
vote
2answers
51 views

How to join the attributes table from one input layer to another layer with unique id using python

I have one input layer with the attibute values and i wanted to join the attribute table of the input layer to the another layer with unique values using python. ...
0
votes
0answers
9 views

dynamic styles for rasters in qgis processing

I am writing a qgis processing script that loops a table column and does interpolation and would like to know if it is it possible to generate styles on the fly for raster layers and how to do it. I ...
1
vote
0answers
22 views

Using Multiprocessing inside a plugin in Qgis

I spent quite a bit of time looking on how to use the multiprocessing package, but couldn't find anything on how to use it inside a plugin in QGIS. I am developing a plugin that does some ...
11
votes
1answer
263 views

How to copy the color styling to a color column in a layer's attribute table?

I have a polygon layer in QGIS that I have applied a random color style to each polygon. Under Layer Properties -> Style I selected a Categorized style and then generated a random color ramp. I added ...
2
votes
1answer
18 views

Checking for Changes in a WFS

I'm responsible for updating many spatial datasets within my organisation. Some data suppliers notify me of a change, some suppliers don't. Sometimes it's not easily apparent if the data has changed ...
3
votes
1answer
40 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
1answer
149 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
1
vote
1answer
48 views

QStringList() error in plugin of QGIS 2.10

I have made a Dialog in PyQt for use it like a plugin under QGIS 2.10 The Dialog works fine like a standalone application, but if I try to call it like a QGIS plugin, I get this error: ...
1
vote
1answer
21 views

Failed to create memory layers in QGIS application on Linux

I have written a python class which reads properties of map layers from an XML file and creates appropriate memory layers. I have developed and tested this code with QGIS 2.8.2 on a Windows 7 machine ...
2
votes
1answer
25 views

How to dynamically change images in map reports?

I need to make a report about several cadastral parcels which data are contained inside three different tables of a database. Report must contain: Cadastral data taken from the three tables A ...
2
votes
2answers
31 views

Where is the QGIS API action for “deselect”?

Where is the QGIS action for the “deselect” toolbutton in the 'Attributes" toolbar? I do not see this action in the QgisInterface class or do not recognize it by name. Is it missing from iface? I'd ...
1
vote
0answers
18 views

How to write a test suite for QGIS standalone application

I have a rather simple QGIS standalone Python app (2.8.2, Windows 7/64), with some published methods to create different types of geometric primitives (rectangles, circles). class MyApp(QMainWindow, ...
1
vote
1answer
37 views

How to calculate zonal statistics from multi-band raster for each polygon using python?

I want to calculate the zonal statastics from multi band raster for a polygon layer. When I am using this snippet of code: vectorlayer=qgis.utils.iface.mapCanvas().layer(0) rasterfile = ...
2
votes
2answers
313 views

How to determine the coordinates of the corners of the raster layer

How can we determine the coordinates of the corners of the raster layer? The image opens function QgsRasterLayer.
2
votes
1answer
61 views

How to avoid a QGIS crash when it is appended a symbol layer in a symbol?

When I run the next code at the Python Console of QGIS with a line vector layer: symbol1 = QgsLineSymbolV2.createSimple({'penstyle':'solid', 'color':'black', ...
2
votes
1answer
53 views

Processing algorithm fails from Python script

I'm trying to write a Python script performing a geoalgorithm. What is surprising me is the following: I first test the algorithm by QGIS (2.8) interface. In my case, the GRASS interpolator ...
2
votes
0answers
17 views

PyQGIS Use of predefined color ramps

I´m trying to apply one of predefined color ramps to a categorized field in a vector layer. To do this, I'm using the code below suggested by Irssvt in another post. However, I cant´t see the result ...
1
vote
1answer
24 views

Styles not applied when using QgsMapRenderer

Using pyqgis, i am trying to export some maps as images using QgsMapRenderer. Here is the layer/style setup, both load correctly: lyr = QgsVectorLayer(uri.uri(), 'Report', 'postgres') styleload = ...
0
votes
2answers
147 views

How to read Oracle data with PyQGIS? (“identifier is not long” error)

Do you have any idea how load Oracle spatial data to QGIS with using the PyQGIS? Is it possible? I try: uri = QgsDataSourceURI() uri.setConnection("*host*", "1521", "*database*", "*username*", ...
1
vote
0answers
57 views

How to wait for mapCanvas render before taking a screenshot?

i am trying to iterate over a large list of features and making a screenshot of the selected feature. My problem is that it seems to be a delay between the refreshing of the canvas and the taking of ...
1
vote
0answers
23 views

How to react to network events

I am in the process of writing a Plugin which should react to some data (XML-Format) sent via a socket connection. Since I have never worked with IPC in terms of python before and my knowledge of IPC ...
1
vote
1answer
40 views

How to get the coordinates inside the polygon using python

I have a polygon and using this code snippet we can get the coordinates boundary of the polygon. canvas = qgis.utils.iface.mapCanvas() aLayer = canvas.currentLayer() coord = ...
2
votes
1answer
27 views

Show VectorLayer in window

I'm new in PyQgis. I can create vector layer and lines/polygons on it : layer = QgsVectorLayer("LineString", "points", "memory") pr = layer.dataProvider() pt = QgsFeature() point1 = QgsPoint(0,0) ...
3
votes
2answers
245 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
40 views

Moving cursor using PyQGIS?

I would like to move the cursor to a given x,y coordinates of the MapCanvas. Is there an easy way to do this using PyQGIS?
3
votes
1answer
1k 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) ...
4
votes
1answer
225 views

Adding new menu item to QGIS Desktop app

I need to add new menu item to the top level menu of QGIS Desktop (2.7.0); I.e. it shall be on same level as "Project", "Edit", "View", "Layer" etc. As far as I know there is pretty nice way how hide ...
1
vote
1answer
152 views

How to enable the snapping options for vector layer using the python programming?

I want to enable the snapping options for the the existing layers using python programming. How can I do this?
2
votes
1answer
38 views

The QGIS atlas defined with pyqgis and a QPT template exports the same maps

I need to generate an atlas for each feature from a layer for reporting. There will be created a few maps. The centre of each map must be focused on each feature. In this task I use a predefined QPT ...
0
votes
1answer
64 views

Accessing layer's visibility presets?

is there a way to programmatically access the layer's visibility presets defined in the layer tree view widget ? (methods, properties ... ?) Thanks ! To avoid misunderstandings the part i want to ...
2
votes
1answer
36 views

QGIS crashing/failing when dissolving multiple shapefiles in a Python loop

I am using QGIS 2.10 (but I've also tried 2.8) to loop through all the shapefiles in a folder (those ending in .shp) and perform a dissolve function on each of them. However, when I run the following ...
6
votes
1answer
2k views

How can I add button to the QGIS toolbar or create my own toolbar?

I want to create a button and add it to the QGIS toolbar or alternatively create my own toolbar and add the button here. A plugin should be started when the user clicks the button.
1
vote
0answers
40 views

How to define a custom function that returns value of a field in an unsaved form

Filter expression builder in QGIS 2.8 allows us to define custom functions using python. I'm intrested would it be possible to define a function which returns a value of a field in an unsaved form ...
1
vote
1answer
26 views

Python ogr filter attribute SQL

I have a shapefile with 4 attribute fields (MC_ID, MC_info, C_ID, C_info). I want to change some MC_ID values selecting the features by C_info. For example: I want to set MC_ID = 2 for C_info = g19, ...
1
vote
1answer
28 views

Valid shapely dumps WKT becomes None when used as input to QgsGeometry

I'm trying to produce a multipolygon feature in QGIS. I am producing filled contours with Matplotlib, taking the multipolygons representing each contour level, using shapely to produce WKT, and then ...
2
votes
1answer
346 views

Display plugin icon [closed]

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. ...