Tagged Questions

Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
1answer
81 views

How do you Select an existing vector Layer and Edit it, using python?

I'm developing a small plugin that needs to be able to select a vector layer programatically based on what layer the user has selected. However I'm not sure how to do so. I believe I found the two ...
4
votes
1answer
803 views

QGIS Zoom from python console

What are the commands to apply all types of zoom (full, on selected layer, etc.) in python console? I'm searching both on pyqgis cookbook and API documentantion, but I'm not finding anything ...
2
votes
2answers
1k views

Extract coordinates from vector layer in PyQgis

In Qgis, I have made a polygon, and from that polygon I have made a vector grid via research tools-> vector grid. The grid covers the entire polygon. Now I want to extract these grid points in the ...
4
votes
1answer
193 views

How to auto-start a pyQGIS thread?

having build some (two) minor plugins, it's now time for me to link a few (perl-) applications to qgis. As there is no perl-interface in qgis I thought the best way to link both worlds together is a ...
3
votes
1answer
557 views

Handle add new feature event and/or access feature before commit?

Is it possible with PyQGIS to catch "add new feature" event before commiting changes on the layer? or at least to access new features before commit.
4
votes
1answer
285 views

How change border line to no pen with python console?

From Python console I load a shapefile with qgis.utils.iface.addVectorLayer. How I can remove border lines (change to no pen) in the active layer?
1
vote
1answer
136 views

Get feature while editing

I have created my custom form for features editing, using layer.setEditForm("form.ui") and layer.setEditFormInit("init") properties. init method receives dialog, layerId and featId as arguments. ...
3
votes
2answers
188 views

Merging polygons at county level to state level

I have a shapefile that represents counties (admin 2) only, but I need to create a state level (admin 1) polygon file (I'm using QGIS). I will need to sum up (or average) the relevant data at each ...
2
votes
1answer
118 views

How to get a list of all projections that are currently available in QGIS via the PyQGIS-API

i'm building a QGIS-Plugin and i want the user to choose a CRS out of a combobox in which the coordinates he would enter into some textfields are represented, so these can be converted into another ...
1
vote
1answer
120 views

Raster menu does not have any tools in QGIS

in raster menu in QGIS, only raster calculator is available, how to get other tools, like wrap (reproject) please see the image for help. help me to get this.
5
votes
2answers
1k views

How do I use QGIS python console to iterate through simple layer queries and png outputs?

I'm really new to QGIS coding and I'm having a hard time finding (especially) the api classes/functions to carry out actions of the Query Builder window. I'm basically trying to do this: Iterate ...
1
vote
1answer
653 views

How do I copy all feature attributes to a feature in a new layer?

I'm trying to create a new layer in QGIS based on an existing layer. The new features should have all the attributes of the corresponding features in the original layer. I've been trying to use ...
2
votes
1answer
1k views

How to apply a graduated renderer in pyQGIS?

Just trying to run the following code already given in the pyqgis cookbook to create graduated colors symbology (as in example with 2 classes) I define the source info for the shapefile but when I ...
1
vote
1answer
411 views

Why do I get 'KeyError: 0' when using Line Intersection tool?

I'm using Quantum GIS version 1.8.0-Lisboa and trying to create intersection point using Intersection tool. (Vector -> Analysis tools -> Line Intersections ) But when I do that for my shapefile, It ...
1
vote
0answers
285 views

DLL problem with PyQGIS

I am having problems with Python Shell importing the module "qgis.core". When I type "import qgis.core" the Shell ("idle.pyw") gives me this error: Traceback (most recent call last): File ...
3
votes
1answer
556 views

Getting dataProvider from vector layer outside QGIS

I'm using PyScripter to explore PyQGIS API because of it's very handy auto-completion function. I've managed to get a handle on a PostGis vector layer by: >>> from qgis.core import * ...
8
votes
1answer
3k views

How do I maintain a resposive GUI using QThread with PyQGIS

I have been developing some batch processing tools as python plugins for QGIS 1.8. I have found that while my tools are running the GUI becomes non-responsive. The general wisdom is that the work ...
5
votes
1answer
2k views

How can I Setup Python to recognize QGIS

I want to use QGIS and work with Python out of the console, but I'm having troubles letting the system recognize the paths of some DLLs. Since I couldn't find a good answer on the web, I wonder if I ...
3
votes
1answer
247 views

Join GPS points obtained from .GPX file in Python Console

Having loaded the .gpx file into a new layer from python console, I'm unable to access the gps points in the attributes table. Essentially, i'm unable to join these points to form a polygon ...
7
votes
1answer
171 views

Unable to load .gpx file from Python Console

I'm trying to create a plugin which will extract the gpx files and load them onto the active layer window in QGIS. While I'm able to load it using the QGIS GUI from Layer>New Vector Layer, I'm not ...
6
votes
1answer
1k views

How to transform a selected multipart feature into singlepart features while editing in QGIS?

There are several questions and respective answers for how to make a multipart features Layer into a singlepart features one using QGIS: How to break a single polygon into multiple polys? How to ...
4
votes
0answers
99 views

Is there a way to run the spatial query plugin from QGIS python console? [duplicate]

I want to get all contiguous polygons for every county. In QGIS I can do this manually with a Spatial Query, but for a large data set this result impractical. Is there a way to run the spatial query ...
3
votes
1answer
144 views

Button to add a new line in a non-spatial table without opening the table itself using QGIS?

While using QGIS and having loaded a non spatial table (from PostGIS), is it possible to add a new row to its table attributes without having to open the attribute table first as in here Is it ...
4
votes
1answer
169 views

Can I add entries to the layerlist context menu?

I am implementing a python based plugin for use with QGIS 1.8. Most of it's user interface is contained within a QDockWidget but there are some layer specific controls I would like to append to the ...
2
votes
1answer
143 views

QGIS 1.8 compiled against PyQt 4.8+?

I'm currently running QGIS on Win7 64bit. My installation says it was compiled against and running against PyQt 4.7.1, although according to the Osgeo4W installer and PyQt4.QtCore.PYQT_VERSION_STR, I ...
1
vote
2answers
1k views

How to fix QGIS PyQGIS package?

I have a broken package that is preventing QGIS from loading python plugins, updating itself, or even un-installing. The main symptom of this problem is the following message that appears when QGIS ...
1
vote
1answer
443 views

How to change cursor shape in pyQGIS?

I noticed that PyQGis has QgsMapToolPan() and QgsMapToolZoom() functions, and the cursor shape on the canvas will change to a hand (for pan), magnifying-glass(+/-) (for zoomIn / zoomOut). I have a ...
2
votes
1answer
224 views

Why shapefile loaded in canvas always appear in random color?

I created the simple frame .UI file, compiled with pyuic4, and tried the ShapeViewer.py to load the shapefile "world_borders.shp". However, the map is always loaded in different random colors every ...
7
votes
2answers
127 views

How do you obtain the execution times of processes in qgis?

I am working on QGIS. I need to determine how much time QGIS needed to finish a specific task. I have been unable to get execution times for the processes. What is the proper way to get processing ...
4
votes
1answer
307 views

Can I use QGIS plugins in PyQGIS as a stand alone script without iface?

Can I use a qgis plugin especially (openlayers plugin) in stand alone pyqgis script? I don't find examples, just code using iface but that cannot used in stand alone script.
2
votes
1answer
597 views

How to debug 'Layer is not valid error' from Python plugin?

I'm trying to understand what goes wrong with a QGIS python plugin. Basically I'm trying to render a series of POINT. The query works fine, at least giving it by hand from inside PostGIS DB: "SELECT ...
2
votes
1answer
2k views

TIN Interpolation using a vector layer

I'm writing a plugin in QGIS and I'd like to generate a TIN surface using a vector layer with x,y and z (interpolation attribute). The idea is to visualize the same result like in the Interpolation ...
11
votes
1answer
428 views

How to create text labels with background boxes?

I'm trying to create some custom labels for point features in a QGIS point vector layer, and I want to write a python plugin to do it. We need our labels to be presented with color tinted rectangles ...
2
votes
1answer
262 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
649 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 ...
10
votes
4answers
2k 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
465 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
1k 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
247 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
524 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
535 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
138 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
590 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
33 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: ...
4
votes
2answers
857 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
338 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
289 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
281 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
194 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 ...