Python bindings for QGIS.

learn more… | top users | synonyms

2
votes
3answers
133 views

Why script works on my computer but not on another?

The script below works perfectly fine in my computer. But when running the script on another computer, I receive an error: Error: Algorithm not found The computer has similar specifications to ...
1
vote
0answers
15 views

How to make both the mouse button click event to do the different function

I am using the canvas event with mouse button click events. def canvasReleaseEvent(self, event): if event.button() == QtCore.Qt.LeftButton: print 'The left button event is',event ...
1
vote
0answers
25 views

Using processing using other output (result from another algorithm) as input

I have a problem. I am developing a standalone app in python and I need to use processing algorithms. I was able to use one algorithm without erros but I need to run other processing algorithm which ...
2
votes
1answer
30 views

QGIS toolbars source code

I can see the source code of the core QGIS plugins from the repository in github. But is there any repository of source codes for QGIS toolbars also?
1
vote
0answers
24 views

Custom QGIS 2.6 map tool - mouse click and release issue

I have create a custom map tool for QGIS 2.6, implementing a canvasReleaseEvent and canvasPressEvent. I can't though get the signals to work on one single mouseclick (I have to click twice). My map ...
3
votes
2answers
34 views

Send signal when attributes modified - QGIS 2.6

For a QGIS 2.6 python plugin, I am trying to send a signal when an attribute value is changed (values for an existing feature are updated or added and the attribute form dialog is accepted). This ...
1
vote
1answer
21 views

Why use QgsFeatureRequest() when iterating?

I am unclear on why one should use QgsFeatureRequest() when iterating over a file’s features. Let’s say I would like to print out all IDs in my currently active dataset. Now, most examples will ...
5
votes
2answers
42 views

Start QGIS with virtualenv Python

is there any means of telling QGIS to use a different Python installation than the default, system-wide one? E.g. use some virtualenv Python /myvirtualenv/bin/python instead of /usr/bin/python? ...
2
votes
0answers
34 views

How to select the features by freehand in qgis using python programming

I have one polygon layer with 10 features. when i draw a line by free hand on the polygon layer it has to select the features. But when i am using qgis.utils.iface.actionSelectFreehand().trigger() ...
2
votes
0answers
34 views

Efficiently generate Voronoi layers in qgis via Python

The following python commands both appear to function when called in qgis 2.6 to generate Voronoi diagrams: processing.runalg("qgis:voronoipolygons", pointLayer, 1, None) ...
2
votes
1answer
72 views

Run processing toolbox outside QGIS in standalone app

I am developing a standalone app in Python, using QGIS libraries including processing algorithms. I am developing in Linux environment and I put the libraries in a folder. Also I put the processing ...
1
vote
1answer
38 views

How to create a text file containing layer names in QGIS?

My QGIS ToC contains layer groups and some layers that do not belong to any group. I would like to create a text file containing the name of those layers that do not belong to any group. Is there an ...
2
votes
0answers
34 views

How do the architecture in qgis plugin creation is linked with eachother using plugin builder?

I am just trying to understand how the architecture or the workflow is linked each other while QGIS Plugin creation using plugin builder. It would be better for me to understand if anyone explains ...
1
vote
1answer
19 views

If statement using QgsRasterCalculator

So in the sequence of my previous question (Can't use Raster Calculator with two different rasters), I am stuck again in my project. With my source rasters, I created 3 different outputs using ...
2
votes
0answers
26 views

QgsRubberBand with holes

I tried to create a QgsRubberBand object with holes, but failed: rb = QgsRubberBand(iface.mapCanvas(),True) geom = QgsGeometry.fromWkt("POLYGON((0 0,4 0,4 3,0 3,0 0),(1 1,3 1,3 2,1 2,1 1))") ...
1
vote
1answer
25 views

QGIS 2.6 : Programmatically setting key value pairs for ValueMap widget

Using QGIS 2.6 and Python 2.7 on Windows 7, I am trying to programmatically insert key value pairs into a ValueMap widget via a csv file. Issue is that some of the values are properly inserted and ...
1
vote
0answers
20 views

Error while creating QGIS plugin

I tried developing a python plugin in QGIS2.6 following the instructions in the link http://anitagraser.com/2014/04/26/getting-started-writing-qgis-2-x-plugins/.When I launch the plugin in QGIS after ...
1
vote
1answer
55 views

Load the raster image which is in TIF format using QGIS API

I am quite new inthe field of GIS. I am interested in is to load the raster image which is in TIF format using QGIS API I have followed the steps given the in the follwing link to load shape file ...
1
vote
1answer
22 views

How to select features using an expression with pyqgis?

How can I select features with pyqgis using an expression? I tried to use an QgsExpression but the select method doesn't take it: exp = QgsExpression("'ogc_fid' = 482") cLayer = ...
1
vote
1answer
28 views

How to zoom to selected feature with QGIS Python Console

I want to select a feature by ID and zoom to it. I tried the following but the canvas doesn't change. Any ideas? canvas = qgis.utils.iface.mapCanvas() cLayer = canvas.currentLayer() cLayer.select(51) ...
0
votes
2answers
54 views

Is there scripts of QGIS core plugins available anywhere?

Is there anywhere I can see the scripts of the Qgis core plugins.
0
votes
1answer
25 views

User Interface file compilation using OSGeo4W shell during qgis plugin creation

I am trying to build a plugin in Qgis2.6 using plugin builder. And as a part of the same, I tried compiling the .ui and .qrc file using OSGeo4W shell. It is showing an error during compilation in ...
6
votes
1answer
71 views

Why the order of imports matters in a standalone PyQGIS processing script?

I've come across a weird issue while running standalone PyQGIS processing scripts. The order of imports in the script affects its normal execution. You can reproduce the problem by opening a Python ...
1
vote
2answers
28 views

How can I disable logs being created in standalone python script?

When I run the following script in QGIS 2.6.1, it produces a folder called 'processing', which contains a log, in the directory it reads files from. And since the script reads files from several ...
2
votes
0answers
47 views

How to modify current QGIS canvas from python script?

I want to zoom into the current active QGIS canvas from a standalone python script. I tried the following but it doesn't impact the current QGIS canvas: import qgis.utils canvas = ...
2
votes
1answer
54 views

How to get shapefile extent from standalone script?

I am trying to obtain the extent of a polygon in a shapefile. I am running a standalone script which will create a grid based on the extent of the polygon. I have tried 2 methods: one from the ...
3
votes
1answer
36 views

How to add a column/feature with PyQGIS 2.x?

I'm using PyQgis 2.2 and I'm creating a plugin. I want to add one feature/column to a shapefile. But I get error.. I've tried to do this as it's shown in Cookbook: if caps & ...
3
votes
1answer
53 views

Removing a vector layer from QGIS [duplicate]

Considering my program is generating a shapefile that has to be added to the "Layers" tab in QGIS interface. However, once the utility of the layer is completed, I need to remove the layer in the ...
3
votes
0answers
14 views

Error writing buffered memory layer to shapefile in QGIS

I have created a memory polygon layerin my QGIS plugin. Then I added a buffer based on a point. I can see the ploygon layer in the map canvas and I can save it to a shapefile from the main GUI. But ...
2
votes
2answers
89 views

IdentifyFeature() use via PyQGIS?

Intent is to have two variables (QgsVectorLayer and feature.id() within said layer) as input for the Identify feature map tool in Qgis (2.6). Wondering if a feature can be selected programmatically ...
1
vote
3answers
67 views

How to use PyQGIS spatial index efficiently?

The PyQGIS Cookbook explains how to set up the spatial index but it only explains half of its usage: create spatial index — the following code creates an empty index index = QgsSpatialIndex() ...
1
vote
1answer
78 views

How to add fields to shapefile from standalone script?

When I run the following script via OSGEO4W64 Shell, I receive the following error when trying to run the qgis:fieldcalculator algorithm: 'NoneType' object has no attribute 'mapCanvas' I read ...
1
vote
1answer
52 views

getting a plugin path using Python in QGIS

How to get a plugin path using Python? I tried QgsApplication.pluginPath() I got u'/Applications/QGIS.app/Contents/MacOS/../PlugIns/qgis' But I actually store the plugin in ...
0
votes
0answers
17 views

How can I include a color legend for my marker colors when i used a QgsCategorizedSymbolRendererV2?

I have this function that sets the marker color to a different RGB value depending on the attribute price level. I would like to also add a color legend showing the marker color with the level of the ...
2
votes
1answer
149 views

Problem with import qgis.core when writing a stand-alone PyQGIS script

I am trying to write a stand alone python script in windows 7 that uses qgis.core and various other qgis libraries. I have found an old question on this subject here: How to write standalone Python ...
0
votes
0answers
17 views

NameError: global name 'QgsDataSourceURI' is not defined

Following on from my previous question I cannot seem to get my function to run using script runner in QGIS. However, if i type then out in the Python Console then they work and load the layer in ...
6
votes
2answers
209 views

Cannot run standalone QGIS script

I've been trying, along with this post, to run a script in OSGeo4w Shell, outside of QGIS. But I get the following error: ImportError: No module named qgis.core I have also read the following ...
1
vote
0answers
20 views

Searching a table within PostGIS using PyQGIS script

Morning all, I am looking for some guidance in trying to set up a script that will search a PostGIS database using a wildcard and then open a certain file directory that will be in one of the fields. ...
2
votes
0answers
45 views

Via PyQgis how to refresh a modified CSV layer without having to reopen the file?

UPDATED: With an CSV layer Qgis workspace [loaded as a delimited text layer], an external algorithm is ran; outputting (writing) new values to certain rows in the layers source CSV file. The writing ...
1
vote
1answer
59 views

Writing a shapefile using OGR, from Shapely Geometry - No feature added Error

I am trying to write a shapefile from a Shapely geometry using PyQGIS in the QGIS 2.6.0 console. Lines of code before the OGR method to write shapefile: extnt = poly.extent() # gives a QtRectangle ...
1
vote
0answers
36 views

How to change values in a raster file at particular positions?

I have a collection of coordinates which comes from a QGSGeometry object. The shape is a polygon. example: qgsGeometry [[(75.2172,17.6566), (75.8499,17.9613), (75.5218,17.2113), (75.2172,17.4574), ...
0
votes
0answers
13 views

How to zoom to the features by selecting the feature with the key event

For zooming to the features first i am selecting the feature and then i am zooming but when i am selecting the feature keyevent stoped working. layer.select(feat.id()) ...
2
votes
0answers
58 views

How to customize the visibility of buttons in QGIS?

The built-in toolbar named "Composer" has an icon "Duplicate Composer". I wish to toggle the visibility of this button in the toolbar. How do I achieve this using pyqgis?
1
vote
2answers
66 views

Vector -> Geometry Tools -> Extract Nodes equivalent in PyQGIS API

My question is fairly straight-forward. Would anyone know the PyQGIS equivalent of the Extract Nodes tool in QGIS? I don't seem to find it in the API documentation. If you do, kindly share the ...
2
votes
2answers
126 views

How to use QGIS explode lines 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 * ...
1
vote
0answers
19 views

How do I step into the C++ functions from an external Python app I'm debugging?

I just wanted to see how to step into the C++ class QgsVectorLayer()'s methods from the python call to QgsVectorLayer(self.uri.uri(),'foo','postgres'). I'm trying to debug and it trying to step into ...
-1
votes
0answers
81 views

Error while launching my own plugin in Qgis2.6

I built a plugin using plugin builder in Qgis2.6.The plugin was created successfully and i copied the folder to Qgis plugins folder.Then i made some changes like adding a combo box using QT designer ...
2
votes
1answer
39 views

Does anyone have any tips on figuring out why a Vector Layer didn't load in Pyqgis?

This is a general question. I'm stepping through the pyqgis code and the layer isValid() is always False. I don't see any error messages showing any reason why it wouldn't load. Other similars have ...
3
votes
1answer
69 views

overlaying raster layer hides my vector layers in PyQGIS

I loaded vector layers and rendered them without a problem but when I tried to add a raster layer as well the map suddenly only shows the raster image and my vector layers are missing. Anything I can ...
1
vote
2answers
54 views

handling QgsVectorLayer (pyQGis begginer question)

I have a simple question. I am trying to start with pyQgis, but I have found it really hard to get a GOOD api Documentation, simple but yet useful. The one of you who did programming in the old ...