Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
0answers
139 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
291 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
80 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 ...
1
vote
1answer
190 views

What is the purpose of some functions and files in QGIS Python plugins?

I'm just trying to understand the architecture of a QGIS Plugin created with the QGIS Plugin Builder, as well as the workflow and the linkage among generated files. If possible, I'd prefer a diagram. ...
1
vote
1answer
41 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
54 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
61 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
29 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 ...
2
votes
1answer
192 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 ...
2
votes
1answer
213 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 = ...
2
votes
1answer
158 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
172 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
101 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 ...
7
votes
1answer
278 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
60 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
71 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
128 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
200 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
192 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
1answer
117 views

Error writing memory layer to shapefile in QGIS

I have created a memory polygon layer in my QGIS plugin. Then I added a buffer based on a point. I can see the ploygon memory layer in the map canvas and I can save it to a shapefile from the main ...
2
votes
2answers
239 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
368 views

How to efficiently access the features returned by QgsSpatialIndex?

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
144 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 ...
6
votes
1answer
246 views

How to get the file name of current style using PyQGIS?

I get the name of the current style file using layer.styleURI(). Then, I change the style file using layer.loadNamedStyle(different_filename). However, when I call layer.styleURI() again, it ...
2
votes
1answer
142 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
48 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 ...
3
votes
1answer
1k 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
54 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
688 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
37 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
64 views

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

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
196 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
48 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
16 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
84 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
365 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
383 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 * ...
1
vote
0answers
55 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 ...
2
votes
1answer
57 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
156 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 ...
2
votes
2answers
161 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 ...
1
vote
1answer
119 views

Loading Vector Layer using python console in qgis

I am using qgis2.6 version and new to pyQGIS. I tried to load a vector file using python console in qgis. I don't know where I am wrong. The layer was not loaded and does not show any error too. Help ...
3
votes
1answer
99 views

Calling canvas.saveAsImage from script in QGis -Qstring problem

I want to create a processing script that saves the QGIS MapCanvas exactly as it is seen on the screen and then Zip up the tifw and a created PRJ. The existing QgsMapCanvas.saveAsImage()-method does ...
1
vote
1answer
127 views

Connecting vector label size with map-units?

I have a working application of labels to a point array - but the size of the text is not relative to the map scale. This decreases the readability of labels when panning and zooming. To resolve~ ...
3
votes
1answer
135 views

PyQGIS: Trying to export layer to shapefile

I´m using python in QGIS 2.2 and struggling with an error trying this: # create layer from text _vlayer = QgsVectorLayer(_ur1, "raw", "delimitedtext") works fine but: # export layer to shape ...
1
vote
0answers
46 views

Is there any alternative for reshapeGeometry in Qgis 2.4 version

I am splitting the polygon feature if it intersects with the line feature. I am using reshapeGeometry() but it is nt wrking in qgis2.4. Is there any alternative to use for this one.it is wrking ...
2
votes
2answers
272 views

QComboBox nested within a Qmenu?

Is it possible to nest a QComboBox inside of a Qmenu within QGIS? Below is my current code and an associated screenshot with the unexpected results. (orange = current incorrect placement, green = ...
1
vote
1answer
57 views

QGIS plugin select and edit features performance issues

I wrote a plugin for selecting and instant updating the value of the selected feature in the attribute table. I tested with a big shapefile and to select and edit 5 features takes ~5 seconds. Which ...
3
votes
2answers
195 views

Azimuthal orthographic projection QGIS2.6

I'm trying to create a globe view in QGIS2.6 with an Azimuthal Orthographic projection using NaturalEarth's 110m countries dataset. I'm following Hamish Campbell's blog post instructions that have ...
4
votes
1answer
127 views

Access ESRI .GDB in PyQGIS

I can access ESRI .GDB data using OSGeo's OGR. The following code gives feature class names embedded in .GDB... from osgeo import ogr driver = ogr.GetDriverByName("FileGDB") data = ...