Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
1answer
377 views

“Couldn't load PyQGIS” Error running QGIS on Ubuntu 14.04

I have installed QGis on Ubuntu 14.04 from the QGis stable repository; it went fine with no errors reported. But when I launch QGis I get this huge window with the following message: Couldn't load ...
1
vote
0answers
49 views

QGIS python plugin: PyQGIS for spatial join

For a QGIS 2.0 and 2.2 Python plugin, I am trying to update one layer's field attribute with another layer's field attribute based on geometry function QgsGeometry.within(). My first layer is a point ...
1
vote
1answer
183 views

models from QGIS 2.0.2 to Python scripts?

I want to automate some tools for QGIS 2.0.2 using Python. Previously I have used ArcMap for automating tools and now i want to use QGIS. In ArcMap I used the ModelBuilder, and more specifically the ...
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
2answers
113 views

PyQGIS: How to send signal if layer is currently in edit mode

I'm looking for a way to send a signal if a layer is in editing mode. I tried editingStarted(), but it wasn't working. I'd like to do something along the lines of the what I have below, but can't find ...
2
votes
1answer
65 views

Finding Code in QGIS Select Features Toolset

Can anyone tell me in what directory the pre-installed Python scripts for the QGIS selection tools (i.e., Select by Point, Select by Polygon) are found? I am using on a Windows 7 installation of QGIS ...
2
votes
1answer
99 views

How to implement 1:n joins with string attribute concatenation?

I have a question concerning pyQGIS. I'm a QGIS long-time (self-learned) user, but just a pyQGIS newbie. I want to implement 1:n spatial join with attribute concatenation in the table. I have a vector ...
2
votes
1answer
99 views

order layer in QGIS with pyqgis

I´m new in pyqgis. I´m looking for a code to move one layer in TOC to a specific position. Is it possible? Thanks a lot!
1
vote
1answer
188 views

How to use Threads in PyQgis, mainly to keep UI active?

I'm trying to develop a plugin, which does heavy computations and as a result, user interface becomes inactive. I know that I should use threads to keep the UI alive (specifically, I have a progress ...
1
vote
1answer
179 views

How can i use python QGis network analysis library to calculate short path based on speed and distance?

I want to calculate and show short path from starting point to an end point in a qgis python plugin. in my research i stopped by an article about QGis network analysis library; ...
1
vote
1answer
73 views

How to batch interpolate many shp´s to DEM

Here´s the problem: I have about 40 shapefiles of contourlines (type line) and I need to interpolate them to create DEM's (tiff, or better some grid format). To do so, some batch scripting would be ...
0
votes
0answers
61 views

error when running a script for clipping a group of rasters on QGIS 2.2 OS X 10.9

I'm trying to clip a group of raster files on QGIS 2.2 (KyngChaos) running on OSX 10.9. When I run the script I get an error related with the location of the files. I'm wondering if this is something ...
1
vote
0answers
44 views

How to include external libraries with my QGIS plugin?

I'm developing a plugin which makes use of "networkx" library extensively. However, networkx is not part of Python libraries pre-installed in QGIS. Is there a way to include this library with my ...
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 ...
1
vote
2answers
251 views

How to calculate distance in meter between QgsPoint objects in PyQgis?

I tried to calculate distance between QgsPoint objects in qgis, i used QgsPoint StartPoint.sqrDist(EndPoint). but i don't find an expected result, i also tried import math ...
1
vote
1answer
117 views

How to populate a combobox with layers in TOC?

I am developing a plugin, and I want user to select one of the loaded layers from a combobox. I've already coded this much: self.dlg.show() layerlist = [] self.dlg.ui.layerCombo.clear() # ...
1
vote
1answer
74 views

How can I use pyqgis to automate a series of field calculations?

I've got a shapefile with about 30 fields that I'll need to update from time to time by importing a CSV with new data, joining it to the shapefile, and using the field calculator to carry the new ...
0
votes
0answers
86 views

How can I get the set of points (cloud) that are a given distance in SpatiaLite?

I have a set of points and need to get the groups of points that are within a distance x. Ie, determining the point clouds that are up to the distance x from each other. Any help would be ...
1
vote
1answer
91 views

reproject vector layer with pyqgis with new CRS does not worl

In QGIS I am running a script in th python toolbar to export all visible vector layers to a GEOJSON with this snippet: canvas = qgis.utils.iface.mapCanvas() allLayers = canvas.layers() for i in ...
1
vote
0answers
80 views

Programmatically modify layer datasource on project save event (QGIS)

I have a QGIS plugin which allows users to add WFS/WMS layers to the map. I would like to be able to scramble the user ID part (token) of the uri when the project is saved/closed and then use my own ...
3
votes
1answer
129 views

Programmatically change layer position in the table of contents (QGIS)

I am trying move/position a layer to the bottom of the TOC by using addTopLevelItem on all other layers. I unsure how to reference the layers as QTreeWidgetItem's. def bg_bottom_level_item(self): ...
1
vote
0answers
42 views

can not delete file after using runalg function

I my plugin I use the runalg function: processing.runalg("qgis:clip",filepath + "/temp2.shp", Layer, filepath + '/' + layerName) vlayer = QgsVectorLayer(filepath + '/' + layerName + '.shp',layerName, ...
0
votes
1answer
200 views

Save as .csv with coordinates in both QGIS 2.2 and PyqGIS

These questions have been asked before, but since they are not answered I will try to pick up the ends here. 1) First, as stated here: QGIS 2.2 saving layer as CSV with GEOMETRY=AS_WKT not working ...
1
vote
1answer
70 views

Run ftools multiparts to singleparts from PYQGIS

Is it possible to run the multiparts to singleparts function from the console with the processing_runalg function? Or is there another way?
0
votes
2answers
242 views

How to copy attribute values of fields in selected features of one layer to another Qgis programmatically?

I am trying to get the values of attributes of the selected features of a layer field by field and copy to another layer that I created in qgis with pyqgis. Is here a example for this. Every example ...
2
votes
2answers
118 views

pyqgis: AttributeError: 'QgsRasterLayer' object has no attribute 'drawingStyle'

qgis gurus. I have a question about pyqgis and hopefully I can get some advise here. I am following http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html. In python console after a raster ...
0
votes
0answers
280 views

Help with scripts for processing raster files with the raster calculator in QGIS

I am trying to process some raster files using python scripts in Qgis 2.20, and I have been having trouble finding any documentation on using raster calculator in scripts being run in the processing ...
1
vote
1answer
255 views

How to add the attributes of selected features to my new layer in pyqgis

I am trying to create a layer from the selected points coordinates. I am drawing a circle to the coordinate of selected points. I also need to add initial attributes of my selected features to my new ...
0
votes
0answers
74 views

Multiparts and Multigeometries: checking for multigeometries with PyQGIS?

I have been working with PyQGIS and writing a small script to check whether the layers I have in the MapCanvas have geometries of type "MultiXX" because I want to run the "Multipart to Singleparts" ...
0
votes
1answer
147 views

QGis: scripting the map rendering (multiple similar maps from one shapefile)

I would like to ask for advice on creating a Python script that will provide the opportunity to render a plenty of similar maps (with the same extent, projection, layout, color scheme and composition, ...
0
votes
0answers
49 views

insertVertex giving false in pyQGIS

I have this code from my plugin which work in Qgis 1.8 and I am trying to make it work in 2.0. I want to insert a coordinate x and y into a polyline after the last entry. points = geom.asPolyline() ...
0
votes
0answers
14 views

Is there an equivalent of QgsMapToolIdentify in QGIS 1.8?

I'm using quantum gis 1.8 Lisbon, and I need to select a point that is on the map by mouse, to know their attributes. But I can not use the QgsMapToolIdentify function, that would show me another ...
0
votes
1answer
19 views

QgsMapToolIdentify(self.canvas)

I am creating a plugin in qgis 1.8.0 and need to get a variable that is saved in the point table. I was thinking about using QgsMapToolIdentify (self.canvas) function, but it gives me error ...
0
votes
0answers
17 views

Query from plugin that shows result on Map and in Attribute Table

I'd like to create a plugin that performs a static (no user input required) query that, based on a condition, selects all the features on the map and displays these in the attribute table. I have the ...
0
votes
1answer
266 views

Replacement of QVariant and setAttributeMap in PyQGIS

I am updating a plugin for QGIS 1.8 to QGIS 2.x. I have the code below. The setAttributeMap does not exist anymore. I have replaced it with fet.setAttributes and it seems to work. When using ...
0
votes
1answer
109 views

How can I reproject a layer in pyqgis?

I have a problem. I'm currently trying to get the extent of a vector layer in latitude and longitude coordinates in python. The layer is currently in EPSG:3857, so .fullExtent() is not returning what ...
1
vote
1answer
96 views

Alias's in the Attribute Table's Column Preview/Column Filters

We've spent some time setting up alias's in Layers/Properties.../Fields (Fig. 1) for database fields displayed as the column headers in the Attribute Table (Fig. 2). Switching the layout in the ...
0
votes
0answers
170 views

Issue blocking QGIS feature form dialog with Python

I'm not sure where I'm going wrong with this python logic for a custom form in QGIS 2.0.1. There are a few things required by the validation function: that index of combo boxes aren't 0 (first index ...
2
votes
0answers
123 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
1answer
318 views

How to adjust QGIS attribute table view column width using Python?

I'm programmatically opening the Attribute table via Python through a plugin. All of the columns have a default width, but some of the data that I'm using do not fit. It's not enough to be able to ...
0
votes
0answers
96 views

Problem with QgsVectorFileWriter

I am trying to write a python script that when it is called it will take an .sqlite layer and save it as a GeoJSON layer. This will be used in a leaflet app but for now my problem is with this script. ...
1
vote
1answer
65 views

Displaying QGIS layer after loading with Python

I'm successfully loading several layers with Python, but can only get to see them in the map window if I manually zoom to extent afterwards. Once the last layer is loaded I call zoom to extent in the ...
1
vote
1answer
118 views

Python.dll could not be loaded with PyScripter

I'm trying to configure PyScripter with QGIS. I've installed it using OSGeo4W and I'm following instructions to setup a pyscripter.bat file by copying content of qgis.bat file. I have 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? ...
0
votes
1answer
52 views

Retrieve path of running plugin in QGIS

In my plugin's directory I've got some XML settings files that I'd like to parse at a particular point during execution of the plugin. Is there a way to get the absolute path where the plugin's .pyc ...
1
vote
1answer
524 views

Can't select layer in the Road Graph plugin QGIS

I'm trying to use the Road Graph plugin in QGIS 2.2.0. I have tried a few line shape files, but it won't let me select the layer (the option is greyed out). I've tried adding a 'SPEED' field and a ...
1
vote
1answer
234 views

QGIS Map tools and Map canvas--QString errors

I'm trying to learn more about using QGIS Map Canvas widgets and creating custom map tools, so the information from the PyQGIS cookbook is very helpful. After trying to experiment with mywnd.py from ...
1
vote
1answer
195 views

How to clip a raster by a shapefile in pyqgis?

Currently I am working with some satellite images (grib files) in pyqgis. As I want to work only with the cells in my study area, I need to clip the raster by a shapefile. I know I can do this by ...
1
vote
2answers
478 views

How to set Eclipse and PyDev for QGIS when ArcGIS is installed?

I have got a lot problems with the configuration of Eclipse with PyDev in order to develop QGIS plugins. The situation is very weird and frustrating. I can import qgis module using Pyscripter without ...
2
votes
2answers
103 views

How to remove/disable a toolbar via python?

How do I remove or disable a toolbar e.g., Raster, programmatically using Python?