Python bindings for QGIS.

learn more… | top users | synonyms

2
votes
1answer
204 views

How to move the QGIS Layerpanel/Dockwidget programmatically

i'm working on a QGIS-plugin and want to move the default LayerPanel/Dockwidget to somewhere else programmatically. More specific: i want to move it into a tab of my tabwidget. Is this possible? How ...
5
votes
1answer
471 views

How to get pixel size/cell size of raster layer?

After much searching, I've still not been able to figure out how to perform what seems like a simple function: I'd like to get the pixel size/cell size of a raster layer using PyQgis. Is there any ...
9
votes
4answers
1k views

How to buffer in pyQGIS?

I'm looking for some examples to do simple python scripts in QGIS. How would I do a buffer analysis on a dataset? I can't seem to find much in the manual and QGIS python that quite matches the Esri ...
3
votes
1answer
293 views

Why are the features in my memory layer not displayed?

I am trying to create a memory layer, I followed the directions from the page below but no points appeared on my map. First I tried typing each line into the python console and I also create a plugin ...
1
vote
1answer
965 views

rpy2 installation ERROR “Tried to guess R's HOME but no R command in the PATH”? [closed]

I tried to install rpy2 (pip install rpy2). I want to use the SDAPP4 extension with QGIS (QGIS shows up the message missing rpy2...). The system tells me always the same error: Tried to guess R's HOME ...
1
vote
1answer
177 views

QgsVectorDataProvider.createAttributeIndex() fails in QGis 1.8

Adding an Attribute Index to a Shapefile fails for a Python Plugin in QGIS: For example - the following python Code in a Plugin ly = QgsVectorLayer(data_source, layer_name,"ogr") prov = ...
5
votes
1answer
439 views

How do I allow users to select features with the mouse?

I am using PyQGis API to create a custom application. How do I allow users to select features with the mouse? Is there a mapTool for this? Surely with a product as powerful as QGis there must be. ...
5
votes
1answer
306 views

How to call GRASS modules in pyQGIS?

I wish to use a Grass module (v.to.db) in QGis, without the grass toolbox. I tried with the Python console, but to no avail : Using Sextante plugin but obviously it didn't know all the grass ...
1
vote
1answer
118 views

Is there a straight way to copy or clone a QgsVectorLayer Object?

Is there a straight way to clone or "deepcopy" a QgsVectorLayer Object with python? Unfortunately the python module "copy" is not successfull with that. Thanks in advance! nikolaus
1
vote
1answer
2k views

How can I fix “ImportError: No module named qgis.core”?

First of all, I'm using Python 2.7.3, QGIS 1.8 (Lisboa) on Windows 7 pro 64 bits. Now let's go to the actual question: I have written some code (Python) that works well within the QGIS built in ...
2
votes
1answer
503 views

How to meet “Contour plugin” and “Profile Tool” dependencies in OSX?

So I have two similar but different issues than my previous question, one I may have mentioned already. When attempting to install the Contour plugin I am told I need matplotlib, which I have on my ...
2
votes
0answers
32 views

How can I set python path and version for QGIS? [duplicate]

Possible Duplicate: Couldn’t load SIP Module When I'm starting QGIS I'm getting the problem: "Couldn't load SIP module. Python support will be disabled." And there is also: Python version: ...
2
votes
2answers
501 views

How to show a message box in QGIS?

I am starting to develop a plugin for Qgis using python, which i am very new at, and would like to view some results of variables by displaying a message in QGIS. How can I do this?
4
votes
2answers
257 views

How to iterate over selected layers?

In QGis by pressing shift or ctrl keys a user can select multiple layers in toc. How can a python script iterate over selected layers? I'd expect a iface.selectedLayers() but I can find only ...
2
votes
1answer
216 views

Can I Dynamically Update Symbol Ranges?

Background: I'm currently trying to dynamically change the ranges for a layer with new style graduated symbology. Problem: I thought it may be as simple as updating the ranges for the existing ...
1
vote
2answers
200 views

How to do a spatial search without select() using PyQGIS?

Using QGIS 1.9.0-master, I want to do a spatial search for features in a vector layer without selecting them, i.e., without using QgsVectorLayer.select(), QgsVectorLayer.selectedFeatures() et al. ...
1
vote
1answer
159 views

Count the number of symbols in a 'new symbology' renderer from pyqgis

Background : I create a lot of symbology using 'saturation' ramps - for want of a better term, e.g. where the hue and value of each symbol stays the same, but the saturation changes. I couldn't figure ...
1
vote
0answers
60 views

What is the proper way to do an automatic rollback of a vector layer edit?

I'm trying to rollback automatically the changes in features of a in-memory vector layer that don't meet certain criteria. The code I'm using for testing looks like this: ... def some_function() ...
3
votes
1answer
460 views

Get extents of vector shape features in python

i am just wondering if it is possible to iterate through vector features and return the extent per feature without clipping the vector shape? The code looks like this and comes from the ...
3
votes
1answer
381 views

Creating Selection MapTool in PyQgis Custom Application

I'm developing a custom GIS application using PyQgis API. How can I let the user select features on the map using Maptools? I would like to replicate the select feature there in Qgis to make the ...
1
vote
1answer
154 views

Is there any python function to rotate map layers?

Is there any python function allowing a user to rotate map layers in the map canvas. If so, could you please point this out for me? I want to rotate a map layer, using a factor of rotation in ...
3
votes
1answer
284 views

Is it possible to programmatically add calculated fields?

In the Memory provider described in PyQGIS Cookbook or in question How to create a new empty vector layer programmatically? I can see how to create a vector layer programmatically using standard ...
1
vote
2answers
282 views

Cannot get changeAttributeValues() to work in a loop

I'm trying to use QGIS to loop through a set of points, find their elevation from a DEM and use that value to update the point layer's attribute table. The loop works fine until I try to use ...
4
votes
2answers
593 views

How do I get the path of a project, or layer file in PyQGIS?

I am generating new raster files from vector layers on a project. I would like to save them in the same directory as the project or layer files. How do I find this path using PyQGIS?
1
vote
0answers
214 views

Qgis Plugin development with postgres data

can someone help me with initial developing on qgis plugin that displays postgres data table on a QTTableView or QTTableWidget? So far: I can connect to database using psycopg2 or using ...
1
vote
0answers
66 views

SVG markers with PyQGIS

How do you SVG-marker layers in PyQGIS? I'm importing a vector layer and want to display it with SVG-markers. It seems that QgsSvgMarkerSymbolLayerV2 does not exist in PyQGIS...
1
vote
1answer
454 views

how to get the projection from a vectorlayer in qgis?

Hi I am trying to set the projection on a raster to match that of a vector point layer. Thus I need to findout what is the projection of a give layer, to use it in the GDAL.Dataset.SetProjection() so ...
4
votes
1answer
347 views

How to Create a raster layer from a numpy array using pyqgis?

I am working on a plugin for Qgis to calculate spatial Kernel density maps. I have all the calculations working, all I am missing is a way to turn a Numpy Array, with density values into a multiband ...
3
votes
1answer
962 views

QGIS: How to load feature (.qml) styles from python? [duplicate]

Possible Duplicate: How to style a layer from console? I'm trying to set the styles for a vector layer by loading the .qml file in the python console. The qml-style file contains all ...
2
votes
1answer
202 views

Is it possible to set a layer style (e.g. set the color ramp) before loading the layer using pyQGIS?

I am implementing a tool which allows an user to calculate some statistics with some data from the registration office. My question is, can I set some layer styles using pyQGIS? The analysis part is ...
2
votes
1answer
491 views

How to split geometry collection into its items using Python and QGIS API?

I'm getting some geometries via intersecting lines by polygons (somewhat blindly - I don't really know if intersection exists and actually I don't need to know) using python and QGIS API: ...
0
votes
1answer
800 views

pyqgis: How to get features of selected geometries

I wonder if anybody could provide an example how to get the attributes of selected Features? I tried the folowing Code in the python Console - but I'm stuck at the point where I'd like to get the ...
2
votes
1answer
133 views

Color depending on attribute

I'm trying to set the color of a vectorlayer feature depending on the feature attributes with PyQGIS. How do you acces the attributes of a vectorlayer feature?
2
votes
1answer
220 views

Is there an itemSelectionChanged Signal in Attribute Table?

The QgsVectorLayer class emits a selectionChanged() signal . If a QGIS user for example selects a record in the Attribute Table of a Vector Layer - a selectionChanged() signal is emitted an can be ...
4
votes
1answer
784 views

How to find all intersections and count lines arriving at each intersection?

I'm having a hard time getting off the ground with this, and am trying to move away from ArcGIS / arcpy. I have a shapefile with a network of polylines. I want to find/count all 2-way intersections, ...
4
votes
1answer
1k views

How can i obtain the data of one selected feature in QGIS using python?

I have a problem / question regarding python and QGIS. Is it, and yes how, possible to get the data of one selected feature in QGIS using python? In my example I have a layer which shows some parcels ...
6
votes
1answer
1k views

When iterating over a vector layer with pyqgis, how do I check whether a feature is selected?

While iterating over a vector layer using the following code (summerized from the example in the pyqgis cookbook), is there a way to check whether a feature is selected? provider = ...
6
votes
1answer
663 views

How to add a toolbar via python?

Through tutorials I learned how to add a toolbutton to the plugins-toolbar via python. Now I wonder how to add a complete toolbar with toolbarbuttons via python. Can anybody give some example-code? ...
1
vote
0answers
189 views

no module named core

Hi I am trying to access and use QGIS modules/class/methods from IDLE on a mac. I have had the same problem as a few other people, and browsing the forums have tried to follow the advice they have ...
0
votes
0answers
132 views

How to build QGIS with Python on Redhat?

I'm attempting to run QGIS on Redhat 5 64 bit architecture. Version of Python is 2.4.3. Version of QGIS is 1.7.4 (wroclaw). When I run qgis, the splash screen appears, followed by a QMessageBox that ...
8
votes
2answers
2k views

How to create a new empty vector layer programmatically?

I am new to python and QGIS. I have looked at a few tutorials of python scripts for QGIS. All of them create new vector and raster layers with some existing data source. eg. shapefile or geotiff or ...
2
votes
0answers
667 views

legend groups and layer position/order qgis 1.8

I'm tring to programmatically create layer sequence also using groups. Simple python code: layer = QgsVectorLayer("004cp000.shp", "004cp000", "ogr") QgsMapLayerRegistry.instance().addMapLayer(layer) ...
1
vote
0answers
426 views

How to change feature's geometry?

Hy, I'm creating my layer like this: crs = core.QgsCoordinateReferenceSystem(4326, core.QgsCoordinateReferenceSystem.EpsgCrsId) uri = "Polygon" uri += '?crs=' + crs.authid() uri += ...
0
votes
1answer
580 views

Is getting wrong attribute values from a feature in qgis

I make two polylines features(in my example both consists of two points) with the add feature tool. Then I (with code) add some attribute values on the first feature, then changes the geometry of the ...
2
votes
1answer
70 views

Which class should I use to work with vector layers?

I'm doing different operations on vector layers. Kindly suggest which class should I use for vector layer i.e QgsVectorLayer or QgsVectorLayerDataProvider.
1
vote
1answer
383 views

How to get a signal when the geometry to a line in QGIS is changed

I am working on a plugin in QGIS and want to get a signal when the geometry to a feature(in this case a polyline) in my layer is changed. For example if I use the node tool to drag one of the nodes. ...
1
vote
0answers
29 views

qgis.core error [duplicate]

Possible Duplicate: qgis.core import error I am new in quantum gis and python, I installed quantum gis 1.8 from osgeo4w installer, after I installed python 2.7 and started python shell and ...
3
votes
2answers
264 views

How do I specify the position, style and units of the ScaleBar in pyqgis?

I would like to add a scale bar to my composition using the python console and then export it to a raster image. I am following the MapRendering tutorial with the "output using map composer " approach ...
2
votes
1answer
397 views

How to load a postgres view using pyQgis?

Under Qgis 1.8 on Windows 7 I have this problem with my pyArchInit plugin: I need to load on the map canvas my geometries from a postgis layer. Till the 1.7.4 version I use the method explained on the ...
8
votes
4answers
1k views

How to run sextante algorithms outside of qgis python console?

I'm kind of stuck trying to figure out the way to run sextante from a standalone python from OSGeo4W distribution. The reason I want to do this is that I got tired entering parameters in the dialog ...