Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
48 views

QGIS 2.8 starts with an error and I am not able to run Python console

I have installed QGIS 2.8 - Wien on Linux Red Hat 7. Unfortunately when I start the application I got this python error: {Couldn't load plugin 'processing' from ['/usr/share/qgis/python', ...
1
vote
1answer
60 views

How to create empty polygon shapefiles with the same field names using python?

I'm new to python scripting in GIS and I have a list with species names, for every species in the list I want to create an empty polygon shapefile with the same fields inside the attribute. I read How ...
1
vote
1answer
18 views

Change page setup in composer window using the QGIS API

Is it possible to use the QGIS API to change the orientation within page setup in the composer window. We have a plugin that builds a map template based on user defined options. When they choose to ...
4
votes
1answer
151 views

Why can't I copy values from a virtual field to a non-virtual field using PyQGIS?

Using the python console, I am trying to copy values from a virtual field into another non-virtual field. Both fields are integer types but I get NULL in the non-virtual field. I followed the answer ...
1
vote
1answer
111 views

Problem with Memory storage type in PyQGIS when updating with auto form

I have a layer of "Memory storage" type (Memory provider) which I created with Python. When editing=on and updating values using the attribute table interactively everything works as expected, i.e. ...
2
votes
1answer
27 views

PyQgis - saga:catchmentareaparallel parameters

in PyQGis i want to use saga:catchmentareaparallel algorithme, in the parametres there is an optionnel arguments , and i don't want to use theme , what is the value should i put on the argument?? i ...
0
votes
2answers
58 views

PyQGIS open layers map is not seen correctly in PNG file saved through QgsComposition, Looks like partially loaded

I have created a python script to create a map which contains 3 layers. 1 is polygon layer administrative boundaries, 2 is point layer, 3 is openlayer plugin map. I want to export this as an image in ...
1
vote
0answers
36 views

Algorithm for re-numbering duplicate feature IDs based on distance along line (PyQGIS and QGIS 2.8)

I've got something working for QGIS 2.8 using Python 2.7 on Windows 7, but I am missing an important part of the puzzle. I'm trying to develop an algorithm to number homes. I've now come to a point ...
1
vote
2answers
44 views

pyQGIS version of the arcgis tool dice

I'm using QGIS and I have some large features that need to be diced up into features with less vertices. If I were using arcGIS I could use the dice tool If I were only interested in lines I could ...
4
votes
1answer
68 views

How to add an attribute with QGIS 2.8.1 Python console?

i would like to add an attribute with the python console: from PyQt4.QtCore import * from PyQt4.QtGui import * layer = iface.addVectorLayer("C:/donnees_SIG/05.shp","nou","ogr") layer = ...
2
votes
0answers
43 views

QGIS not interacting with iface from python class

So I'm working on something where i need to use threads from python console of QGIS. The following line of code adds layer successfully iface.addVectorLayer("D:\ArcGIS Misc\Atlas\points.shp", ...
3
votes
1answer
39 views

How to access CRS of shapefile in standalone script?

I'm trying to access the CRS of a layer and use this to create a grid. I followed the answer in this post which works great in QGIS but I would like it to work in a standalone script. Here is a ...
1
vote
1answer
74 views

PyQGIS: how to delete layer from TOC when attribute table is closed?

I'm developing plugin where I want to be able to edit non-spatial table inside the attribute table dialogue. As it seems that the only way to do so is to add this table to the TOC first, I do so. But ...
1
vote
1answer
39 views

In QGIS plugin, How do I determine when layer visibility is turned ON or OFF (changed)

I need to update a vector layer's data when the visibility is turned back on. My update does not occur when the visibility is off. To what signal do I need to connect to catch the visibility change? ...
1
vote
1answer
46 views

Why can't I load a .shp file with the Python Console in QGIS?

I'm trying to load a shape file into QGIS using iface.addVectorLayer, but whenever I do this, I get an error message "Layer is not valid: etc ..." However, if I try to load the same .shp file use the ...
0
votes
0answers
43 views

How to ceate new vector layers / save output in QGIS scripting?

I need to create a script in QGIS which stores outputs. In this case, official documentation didn't help to me. When I use geoprocessing (processing.runalg()) for vector layers. In some cases, output ...
0
votes
1answer
35 views

How to update raster color ramp with new min/max values using PyQGIS?

I'm trying to update a single band psuedo color renderer with new min/max values from the python console. All the code samples i have been able to find deal with constructing a renderer from scratch, ...
0
votes
0answers
25 views

Add save/commit button to custom feature from

I would like to add a save/commit button to a custom QGIS feature from. This is very helpful when there is a linked table dispayed on the same form - the link will work only once the main table has ...
1
vote
0answers
21 views

How to run the QGIS viewshed plugin from the console?

I want to run the viewshed plugin from the console/ in a script in QGIS. Do you know if this is possible?
0
votes
0answers
13 views

AddFeatures returned values …?

i try to add Features in a polygon vector layer. i'm using for example the following lines : fet.setGeometry(ft_com.geometry()) bool=pro.addFeatures([fet]) bool returns me True (i see the added ...
0
votes
0answers
36 views

Automated Viewshed in QGIS

I want to create a workflow with a QGIS script where I need a viewshed tool. There is a really cool viewshed plugin. Unfortunately I am not able to access it in the QGIS console. I also found out that ...
0
votes
0answers
21 views

pyqgis, features geometry type changes to unknown after copying to anoter layer

Im copying a subset of features from a shapefile based QgsVectorLayer (polyline type shapefile) to a memory based QgsVectorLayer('LineString', layername ,'memory'): ...
2
votes
2answers
56 views

How to write a vector layer as tab delimited txt file using PyQGIS?

I'm using the following QGIS 2.8 Python code to save results to a txt file QgsVectorFileWriter.writeAsVectorFormat(inputLayer, "D:/dstest/my_csv", "CP1250", None, "CSV",True) I would like to be ...
0
votes
0answers
66 views

Identifying Left and Right Mouse Button Clicks in PyQgis application

I am relatively new to PyQt. I am trying create a custom plugin for Qgis which enables the user to select some features by drawing polygon on the canvas using mouse clicks and then performs ...
0
votes
0answers
51 views

How to create a Shapefile of a subset of input features in PyQGIS?

I'm having some trouble applying my Python skills to develop some scripts in PyQGIS. For me it's far simpler to write it in ArcPy, but then again I wouldn't get that much satisfaction after finishing ...
0
votes
0answers
10 views

Range problem in QDoublespinbox for different projections of data in QtDesigner\python

I have two QDoubleSpinboxes that updates the value of latitude and longitude of a point respectively. The data is in the CRS "EPSG:32643 - WGS 84 / UTM zone 43N" I had also set range of the ...
1
vote
1answer
42 views

QGIS Python Scripting permission denied

I've just started a Python Scripting tutorial on QGIS. The problem arrives right at the end, when I have to use this script: output_file = open('c:/Users/Ujaval/Desktop/airports.txt', 'w') for f in ...
2
votes
3answers
77 views

Is there any way to freeze the layer names in the TOC?

I would like to freeze the names of layers in TOC. Is there any way to do this via QGIS config or PyQGIS? I´m using QGIS Wien.
3
votes
1answer
55 views

fTool in pyqgis: Is it possible?

I am doing a work which I need to sample random points for many layers (classification of land use). Then, I'm trying to do a loop with my several layers and applied a functions of random pointos. I ...
1
vote
1answer
73 views

Logging layers openings?

i would like to log every layers openings in PyQGIS, regardless of the opened project. Is there a way to achieve that ? Where should be the Python code be located in that case ? Thanks for your help ! ...
1
vote
2answers
118 views

Create a script to add delimited text layer in QGIS

I'm trying to use QgsVectorLayer() function to add delimited text layer in QGIS. So I have a txt file (T_1999_1_2.txt) in path: "D:\PATRICIA\DOCUMENTOS\ESTACOES METEOROLOGICAS\DADOS METEOROLOGICOS\T" ...
0
votes
0answers
34 views

How to remove a QgsMapCanvasLayer from QgsMapCanvas with PyQGIS || C++?

I try to find a way to remove a QgsMapCanvasLayer from the QgsMapCanvas. At the moment I only can delete the MapLayer from the QgsMapLayerRegistry with: ...
1
vote
0answers
40 views

Adding Oracle Spatial Layer using Python Bindings of QGIS

I want to load a layer from my Oracle Spatial Database using the Python bindings of QGIS. I have tried loading the layer by creating the uri as shown in some previous posts. I am using the python ...
1
vote
2answers
39 views

How to add an image to canvas?

I am trying to make a QGIS plugin using Python. Right now I need way add an image to canvas but I don't want that image to be a new layer in qgis project. Is there a way to do it? Now I have: ...
2
votes
1answer
47 views

Unable to compile using make test in Linux

While trying to compile my test plugin I encounter this error, for the moment I can't figure out why, last week I had some issues on windows but eventually solved them via OSGeo Shell but this time ...
3
votes
2answers
117 views

How to create multiple QGIS layers from multiple text files?

I have a few hundred txt files (each representing a line of a river bed profile) that I need to load as (point-) layers in QGIS. Partial example: 4504764.8331;5374251.3024;397.8871;2 ...
3
votes
1answer
45 views

Getting co-ordinates of current map canvas using PyQGIS?

I'm trying get the extents of the current map canvas. CRS is 22700 BNG. My code: canvas = iface.mapCanvas() print canvas vLayer = iface.activeLayer() extents = vLayer.extent() print extents ...
0
votes
2answers
74 views

QGIS and Google Streetview?

Is there a way to open an (embedded or not in QGIS...) window containing a Google Streetview view at given coordinates using PyQGIS?
1
vote
0answers
33 views

Setting up PyCharm CE 4 to work with PyQGIS library in Mac OS

I am trying to set up pycharm to work with pyQgis library but with not success till now. I am using PyCharm CE v4 and QGIS version 2.8 I have tried to implemnte the instructions of several posts like ...
2
votes
1answer
108 views

How to create and remove multiple QgsRubberBands in PyQGIS?

Currently the following code-snip works great to highlight a shape based on the 'feature' and 'layer' variables: self.rubberHighlight = QgsRubberBand(self.iface.mapCanvas(),QGis.Polygon) ...
1
vote
0answers
33 views

How to add diagrams to a layer in a PyQGIS standalone application?

In my standalone application, I show different layers based on queries into a canvas. Now I want to add a layer with charts over by the values of an attribute. Is it possible in a standalone ...
2
votes
0answers
69 views

Is it possible to use memory layers in QGIS processing algorithms?

I am building a QGIS plugin that connects to a MySQL database in the local network, and then adds a subset of one of the tables to an in-memory layer; the subset is based on data currency (only taking ...
2
votes
1answer
183 views

Can we avoid using SIP library when writing standalone QGIS python script

I wanted to write a small custom python script using QGIS functionality. So I started with the QGIS documentation on the custom application section. After having some troubles with the import ...
1
vote
1answer
50 views

pyscripter : add a legend to my vector layer

I work on PyScripter, i managed to display a vector layer from Postgresql with a symbology. But I have a difficulty to display a legend. def main(): def init(): # appel de l'application et ...
2
votes
1answer
51 views

Multiple ComposerMap items not rendering properly Pyqgis

I am currently trying to put together compositions using inputs from two different map canvases. One is from a canvas built and controlled via a plugin, the other is the the main QGIS canvas (accessed ...
1
vote
1answer
74 views

Save Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?

I have a QGIS composer/print view opened with all elements adjusted as I wish. Now I need to print/save/export this as a PNG or PDF file from Python console/Python script. I do not want to change ...
1
vote
1answer
109 views

PyQGIS - load PostGIS layer as editable

I can load a PostGIS layer on QGIS' map canvas but "Toggle Editing" button comes "inactive". How can I load vector layer as editable? The code given below loads PostGIS layer on map canvas & ...
1
vote
0answers
35 views

Create a checkbox per loaded layer in a QGIS plugin

I want to create check boxes inside a listview in my plugin dynamically based on the number of layers loaded in QGIS. I would like to know is there any similar existing plugin in QGIS so that I may ...
1
vote
1answer
74 views

How to get path for layers listed in a combobox?

I want to get the path of a layer in my plugin, in the console it works fine but in my plugin it gives me the error AttributeError: 'NoneType' object has no attribute 'dataProvider' def run(self): ...
2
votes
1answer
66 views

How to display a picture in QGIS custom form?

I'd like to integrate an UI file as a form in QGIS 2.8. The UI file is created in QT Designer. One of the attributes in the attribute table is a filepath to an image. I'd like to display the picture ...