Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
188 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
-1
votes
1answer
26 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 ...
2
votes
1answer
37 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= ...
0
votes
1answer
20 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 ...
0
votes
0answers
25 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 ...
9
votes
1answer
1k views

Is it possible to show our custom message in QGIS Status bar using python?

Is there any way to show our custom message in Qgis Status bar using python? Just like in arcgis "IApplication.statusbar.message(0) = "Please wait..." like that is there any option to show ...
1
vote
0answers
28 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 ...
4
votes
2answers
531 views

How to add a layer group using pyQGIS?

Good morning, I would like to know how I can create a new group in the layer manager using python code, someone could help me?
2
votes
0answers
21 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
36 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 ...
5
votes
2answers
705 views

Load and display a layer from SQL Server using PyQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
3
votes
0answers
32 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
1answer
38 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
21 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
23 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
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) ...
3
votes
2answers
222 views

How to delete column/field in PyQGIS?

How to remove or delete column fields in a shape file using python?
2
votes
0answers
24 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
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
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: ...
2
votes
1answer
33 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 ...
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 ...
2
votes
1answer
33 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
0answers
21 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
32 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 ...
1
vote
1answer
172 views

How to select and zoom in features from a QGIS Python Plugin

I'm very new to Python. I'm trying to find a way to select and zoom to the features from a QGIS layer. I've created a plugin and built a custom form. I have 3 values from the form which I need to ...
1
vote
1answer
39 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
32 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
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
61 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 ...
2
votes
1answer
232 views

How to load a *.qgs file in a C++ QGIS standalone app?

I'm using QGIS-2.4.0 API to develop a standalone app by C++. I saved a test.qgs file in QGIS Desktop software, in the project, there was one layer and it was visible. Then I loaded the test.qgs ...
1
vote
0answers
14 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 ...
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 ...
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 - ...
2
votes
1answer
166 views

How to add an interpolation raster from the python console in QGIS?

I'm trying to add an interpolation layer based on an existing vector layer by using the Python Console (initially in the menu Raster/Interpolation), but can't find anything related in the ...
1
vote
0answers
46 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
37 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 ...
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
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
0answers
31 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
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)) ...
2
votes
2answers
325 views

How can I access `processing` with Python?

I want to access the explode lines function in Python outside of QGIS from a standalone script. What module do I have to load in order to use it? How can I access processing? from qgis.core import * ...
2
votes
1answer
146 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
1
vote
1answer
34 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 ...
2
votes
1answer
81 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
vote
0answers
28 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 ...
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 ...
9
votes
4answers
3k views

How to get features based on their attributes using Python?

How to Get features by their attributes (similar to Iqueryfilter in arcobjects) in Qgis using python? Instead of getting all features and filter it manually, is there any option to use whereclause to ...