Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
1answer
50 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?
2
votes
1answer
59 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
1answer
44 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 ...
2
votes
1answer
56 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 ...
1
vote
0answers
47 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
32 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
31 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
0answers
53 views

How to change the symbology of selected features in QGIS

In QGIS selected features are normally highlighted in a different color to draw user’s attention on the selection. The default color can be changed programmatically. As a nice to have my standalone ...
0
votes
1answer
71 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 ...
1
vote
2answers
43 views

Importing fmeobjects into PyQGIS

I use FME a lot for manipulation of spatial data, and would like to leverage it's Python library, fmeobjects in PyQgis. If I run the following in my standard Python IDE it works fine: import sys ...
2
votes
1answer
69 views

QGIS Plugins & Tools that replicate Select ArcPy Tools

I developed a complex python application for road generation from GPS Devices that uses a few Arcpy Tools. I want to try and replicate this Applications functionality using a freeware like PyQGIS ...
1
vote
2answers
67 views

QgisInterface.addVectorLayer Error

I am Esri-trained, trying to move into QGIS using Python. Simply trying to add a vector layer in Qgis returns the below error: TypeError: QgisInterface.addVectorLayer(QString, QString, QString): ...
2
votes
1answer
61 views

different way to build qgis python standalone application

There seems to be 2 different ways to start a Python QGIS standalone script. The official tutorial is using : from qgis.core import * # supply path to where is your qgis installed ...
0
votes
1answer
49 views

How can we export shapfile to svg format using Pyqgis

I am doing a project where i have to export file from shapefile to svg format using Pyqgis. i have read some articles regarding simplesvg plugin but i don't know how can we achieve the same task using ...
1
vote
1answer
36 views

How to restrict panning in QGIS to a given extent

I'm going to build a QGIS standalone application. According to the requirements full extent equals to the extent of a predefined rectangle (say bounding box of a parcel). The application should start ...
1
vote
1answer
74 views

Finding and deleting duplicate records in attribute table in QGIS

I have around 1 Lakh+ (100,000+) point features in my shapefile, which has some duplicate records in it. I had found the duplicate records present in the attribute table and print those in python ...
4
votes
1answer
85 views

QGIS Export Shapefile

i am trying to export selected feature using pyqgis. till now i have tried these codes. after using this i can select feature but dont know how to export selected feature to new shapefile. canvas= ...
2
votes
1answer
68 views

Why does the QgsFeatureIterator crash in my stand alone script?

I'm trying to write a standalone script in qgis 2.10 in ubuntu I have written a script which crashes when I run from bash but works fine from inside the qgis desktop environment. The script is: ...
2
votes
1answer
55 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
72 views

How to develop a QGIS plugin to fully run spatial queries with PostGIS?

I am developing a QGIS plugin that fully runs spatial queries with PostGIS. I developed all spatial queries which need some adjustment. I am looking for some resources or documents to know how to ...
1
vote
0answers
51 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
26 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
36 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
70 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
47 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
40 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
46 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
50 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
79 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
42 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
39 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
72 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
43 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
66 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
89 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
107 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
20 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
73 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
48 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
59 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
19 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
87 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
41 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
69 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
48 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
47 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
47 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
35 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
40 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 ...