Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
31 views

Adding QGIS feature, that shows coordinates and scale, into a custom application

I'm writing a standalone application using PyQGIS and I'd like to add the QGIS feature that shows coordinates and scale as the cursor hovers over the map. I need to know this mainly in case of ...
3
votes
0answers
27 views

How to develop QGIS Plugin to fully run Spatial Queries With PostGIS?

I'm developing a QGIS plugin that fully run spatial queries with PostGIS. Actually I developed all spatial queries wish need some adjustment. I'm looking for some ressources or documents to know how ...
1
vote
0answers
17 views

What is the correct way to run a python script in QGIS Open Project macro?

This code (answer from @gcarrillo about other question - Is there any way to freeze the layer names in the TOC?) runs fine on python console and inside a plugin. But now, I tried put it within the ...
0
votes
0answers
21 views

How to call the Qt UI of a script? [on hold]

I'm pretty new in the python world, and I'm working with the python console inside QGIS (Master version on a Debian machine). I have written some scripts, all of them are in the same directory (e.g. ...
0
votes
0answers
10 views

Adding elements to the layer tree view ?

is there a way to add custom elements (checkboxes, or more ...) or change some elements properties (colours ?) in the genuine layer tree view of QGIS using PyQgis ? How should i do that ? Thanks !
2
votes
0answers
21 views

QGIS QgsLayerTreeGroup signal “currentLayerChanged”?

In a pyqgis context, I use the "currentLayerChanged(QgsMapLayer *)" signal of the QgisInterface class to do something when the current layer is changed, but I need now to do the same when I select a ...
1
vote
1answer
32 views

Loading GeoServer WMS raster layer in QGIS Python console

I am using the following snippet to load a raster layer deployed under wms service using geoserver, in qgis python console. I am getting False output. Any idea? registry = ...
1
vote
0answers
12 views

PyQGIS Standalone Crashes python.exe when zooming out too far / Process finished with exit code -1073741819 (0xC0000005)

I have the following PyQGIS Standalone App which is working fine so far. One little problem is that if I zoom out to the MaxExtent(by scrolling the mousewheel) the app crashes python.exe so that the ...
2
votes
1answer
25 views

Error: Algorithm not found (QGIS)

I wrote the following code using QGIS'API. import os from qgis.core import * import qgis.utils prefix_path = os.environ['QGIS_PREFIX_PATH'] QgsApplication.setPrefixPath(prefix_path, True) ...
2
votes
1answer
30 views

How to add a message bar to custom canvas?

There is a simple code to add message bar to main window in QGIS: iface.messageBar().pushMessage("Hello","World") My question is how to add bar to my custom canvas canvas = QgsMapCanvas() in ...
2
votes
0answers
46 views

Remove multiple fields from multiple shapefiles using a python script [duplicate]

I'm using the python console of QGIS 2.8.1-Wien. I have a shapefile with many fields in the table that I want to remove them. I tried to use this geoalgoritm as: ...
1
vote
0answers
18 views

import qgis.core problem with QgsFeature and QgsGeometry ImportError: DLL load failed: The specified procedure could not be found

I've tried several previous answers to similar questions - no luck. I've tried everything, nothing seems to work. This is the error I'm getting Traceback (most recent call last): File ...
1
vote
0answers
17 views

PyQgis - Adding attributes to a POSTGIS layer

After reading @underdark's answer to this question on creating a new vector layer and @Matthias Kuhn's to this one on field calculation, I wrote a script that allows me to calcultate the mean ...
1
vote
1answer
27 views

How to get programmatically selected layers from the QGIS legend?

My QGIS plugin exports all layers from QGIS to KML format. Now I'd like to export only selected layers. However, I can't find any hints in QGIS API. Is it possible to iterate over selected layers in ...
2
votes
1answer
32 views

PyQGIS standalone script does not work. Error “QGraphicsScene::addItem: item has already been added to this scene”

I try to test a PyQGIS standalone script which should just show one Shapefile. Sounds pretty simple but does not work. Here is my script: from PyQt4 import * from PyQt4 import * from PyQt4.QtCore ...
1
vote
1answer
30 views

Adding the map canvas center to a composer label in QGIS

I am able to access the map canvas center in the python console in QGIS using qgis.utils.iface.mapCanvas().center() What I would like to do is get this into a map composer label. Is this ...
1
vote
1answer
37 views

Setting PYTHONPATH for compiled QGIS version on Linux

I'm trying to set the PYTHONPATH in order to be able to load the qgis classes in a python console (not the QGIS Python one). I followed some resources I've found (PYQGIS Cookbook, and others) but I ...
1
vote
1answer
68 views

How to register “events” for linear referencing in pyqgis?

Is there an easy solution for recording events for a line crossing borders of zones in a polygon layer? I need to implement this in python using QGIS, thus pyqgis. The image attached illustrates what ...
1
vote
1answer
58 views

How to select polygon features that intersect a line feature using pyqgis?

Is there an easy way to select all features in a polygon layer that intersect (overlap) a line feature? I need to implement this in python using QGIS, thus pyqgis. This code illustrates what I am ...
1
vote
0answers
13 views

Accessing elements Linestring and points from a DGN file and displaying both layers on QgsMapCanvas

I am using PyQGIS APIs to develop a standalone application which currently display's map data layers on QgsMapCanvas from .shp, .tif, .dgn files. I am able to do it for .shp and .tif but not for .dgn ...
2
votes
1answer
44 views

Checking whether a table is geographic or not …?

all in the title i think : What is the best generic method to check whether an opened table is geographic or not using pyqgis ? Thanks !
1
vote
1answer
34 views

Compile pluging for qgis 2.8.2 with pb_tool or Makefile, in windows

I created my pluging with pluging builder, after compile the resources file, i test my pluging in Qgis. I modify the ui file in QtDesigner, but i don't know how to compile it in order to see the ...
1
vote
0answers
30 views

import qgis geoprocessing tools in python os x 10.9.5

I'd like to use the python bindings from qgis, but in a standalone project. I need the geoprocessing tools for vectors. I updated QGIS (Wien - 2.8), python (3.4.3), etc. However, it always ends with ...
1
vote
0answers
45 views

QGIS python originalName() does not return actual original layer name

I am writing a Python QGIS Plugin, using QGIS version 2.6 as the basis for development. When loading data into the canvas programmatically, I am trying to maintain the spatialite table name as the ...
1
vote
1answer
17 views

Get page coordinates of QgsComposerMap

How do I get the coordinates in page units (i.e. millimetres) for a QgsComposerMap item? I can get the upper left coordinate using pos, but can't see any method that provides access to the width and ...
1
vote
1answer
50 views

How to set CRS in QGIS using pyQGIS

This question is very similar to these one , but it's doesn't work for me. This is my try: ........ vlayer.setCrs(QgsCoordinateReferenceSystem(25830)) ...
1
vote
1answer
33 views

Labeling layers with Python in QGIS. LinePlacementFlags

How could I set LinePlacementFlags with Python in QGIS? My code is something like: palyr = QgsPalLayerSettings() palyr.readFromLayer(layer) palyr.enabled = True palyr.fieldName = "attribute" Then ...
4
votes
1answer
55 views

Select a column like Primary Key in a View from PostGIS using PyQGIS in QGIS

Postgresql doesn't support Primary Key in views. When I load a postGIS view in QGIS "manually", I can choose the column that will be the Primary Key, but I would like to know if I can select a column ...
1
vote
0answers
27 views

compare column to atributes in a loop in pyqgis processing

I am creating a script in processing qgis. I am running the interpolation algorithm.I have two tables table A and table B. Table A contains attributes like A_test,B_test up to Z_test. Table B contains ...
3
votes
1answer
32 views

Table output from QGIS graphical modeler

I have developed my own model, which processes input vector layer. The final output is vector layer that contains many attribute fields, and of course, also the geometry, but I need a simpler output - ...
1
vote
1answer
43 views

Generate maps from different columns of shapefile with QGIS

I have a shapefile with N columns describing different attributes of some features. I would like to generate a grid of maps, where each map is a different column. Visually, I'm thinking of something ...
1
vote
0answers
20 views

Hex grid from layer bounds issue

I'm trying to use the 'Hex grid from layer bounds" script to reproduce the simple "Mapping density with hexagonal grids" from the Learning GIS book. When I run the script "as is" I get the error: ...
0
votes
1answer
26 views

How to solve the Qgis error when try to import a plugin created in lower version than 2.0?

Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 219, in startPlugin plugins[packageName] = package.classFactory(iface) File ...
0
votes
1answer
11 views

PyQGIS - controlling the proxy

I operate behind a firewall at work, and so to access the many very awesome plugins and other external goodies for QGIS I need to use a proxy. We also have our own WMS server - which doesn't like the ...
2
votes
1answer
79 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 ...
-1
votes
0answers
21 views

Extend/Trim Tool in QGiS [duplicate]

Is is possible to create Extend/Trim tool in QGIS using python which is similar to ArcGIS functionality?
2
votes
2answers
60 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
21 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
60 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
21 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
24 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
56 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
32 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
43 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
59 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 ...