Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
131 views

How to create a plugin GUI for QGIS 2.8.2?

I create a pluging with the pluging builder in Qgis 2.8.2. I went to the folder of my pluging : C:\OSGeo4W64\apps\qgis\python\plugins\yu in order to visualize al the files that the pluging builder ...
2
votes
2answers
108 views

How to run Processing qgis:extractbylocation?

I try to use the processing 'qgis:extractbylocation' in QGIS 2.8.2 from the QGIS algorithm provider. import processing # import the layers by a given uri inputlayer = QgsVectorLayer(uriTr.uri(), ...
0
votes
1answer
40 views

Popup menu on Mapcanvas right-click

i would like to have a popup menu when right-clicking the MapCanvas (the identifyFeatures tool does it...) Is it something easy to achieve ? Could anybody give me a starting point ? Thanks !
1
vote
0answers
173 views

ImportError: No module named sip

I have been trying to write a custom application to generate contour from QGIS. This is my starting code: import os; from qgis.core import *; This is the error i am getting: Traceback (most recent ...
1
vote
0answers
32 views

Problem with writing input and output for QGIS user script

I need to write QGIS script, which removes features with same value of specific attribute - in output will be only features with first occurrence of value. I know, how to check duplicity, but I don't ...
0
votes
0answers
30 views

Number of intersected features from one layer per feature from second layer

How can I get number of intersecting features from one layer per feature from second layer using any component from QGIS 2.8 (GRASS, SAGA, Python scripting...)? Result should be stored in new ...
3
votes
1answer
67 views

How to change the “application_name” of a PostGIS-connection in QGIS?

PostGIS offers a view called pg_stat_activity, where you can see all the active connections to the database. This view includes the interesting column application_name. When a connection comes from a ...
2
votes
1answer
47 views

PyQGIS: How to get the list of valid layers in TOC?

To get the list of TOC layer names I used the approach suggested here: for layer in QgsMapLayerRegistry.instance().mapLayers().values(): print layer.name() But this method is not reliable due ...
1
vote
1answer
174 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
92 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
41 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
168 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
121 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
30 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
82 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
42 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
48 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
85 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
52 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
46 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
149 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
50 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
60 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
62 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
64 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
28 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
31 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
14 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
56 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
37 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
94 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 ...
1
vote
1answer
94 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
57 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
13 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
58 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
85 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
59 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
75 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
194 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
68 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
62 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
54 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
67 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
145 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
68 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
94 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
66 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
136 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
35 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
99 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 ...