Python bindings for QGIS.

learn more… | top users | synonyms

3
votes
1answer
352 views

How to calculate all paired shortest path using PyQGIS?

The code for shortest path analysis with PyQGIS specifies start and end nodes explicitly: pStart = QgsPoint( -1.37144, 0.543836 ) pStop = QgsPoint( -1.1027, 0.699986 ) ...
1
vote
1answer
334 views

How to get vector feature by mouse location?

I'm writing a photo grouping plugin. My current problem can be broken up into "end goal" and "baby steps", because I think that's what I want. But if there's a way to get to the end by a different ...
1
vote
1answer
884 views

How to change vector attributes values?

I want to change vector attributes values. i could not get the command fet.setAttribute indeed, it is mentionned in http://hub.qgis.org/issues/7223 that: "The QgsFeature instance now must be ...
3
votes
2answers
949 views

PyQgis overwrite shape file and adding layer to Qgis

I am creating a shapefile in python by: driver = ogr.GetDriverByName('ESRI Shapefile') datasource = driver.CreateDataSource('c:/temp/toke2.shp') layer = ...
1
vote
1answer
359 views

How to write a CSV from Python console in QGIS?

I am trying to write out a CSV file from a vector layer made up of points using the python console in QGIS. I've tried the following command: QgsVectorFileWriter.writeAsVectorFormat(layer_Map, Folder ...
0
votes
1answer
146 views

Split Map using Python in Qgis

I have a map, in which each region is defined as an attribute of the map (I can select each region from the attribute table). I am trying to create new layers each one containing only 1 region using ...
1
vote
1answer
891 views

How to evaluate raster calculator expressions from the console?

How can I execute from the console an expression that should be used with the raster calculator? I'm searching for something like this: qgis.someRasterCalcClass.evaluate("boh@1 + boh@2", ...
1
vote
1answer
274 views

How to use QgsOverlayAnalyzer class in pyQGIS?

I am very new to Python scripting in QuantumGIS, so bear with me please. I am trying to use the QgsOverlayAnalyzer class in QuantumGIS (http://www.qgis.org/api/classQgsOverlayAnalyzer.html#details) ...
4
votes
4answers
400 views

How to display a “Save As” dialog for raster files?

I'm writing a QGIS plugin in python. I need to show a "Save as" dialog window in order to allow the user to select the path of the output raster file. Do I need to create a QFileDialog and manually ...
4
votes
1answer
797 views

How to deploy a QGIS Python Standalone Application with minimum installation size?

I am trying to create a Standalone QGis Application using python. I was able to create the nice looking shapeviewer application by following the steps here. Now I would like to deploy this in ...
1
vote
1answer
162 views

How to begin with tool development for GRASS gis or QGIS GRASS

I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...
0
votes
1answer
534 views

How to read the attribute values using pyQgis?

What is the way to get the information contained in the attribute table, say in column 2, row 2 using pyQgis?
1
vote
2answers
724 views

Where exactly are qgis.gui and qgis.core located?

I'm trying to create a standalone qgis app using pyqgis, i'll be deploying it by copying the install folder of qgis and source folder of my app, and so for the testing purposes i copied qgis install ...
4
votes
1answer
273 views

Personal shell launcher for PyQGIS

I have changed a shell launcher found at http://inasafe.linfiniti.com/html/id/developer-docs/platform_windows.html as to fit my wish: setting the system environment variables to be able to use PyQGIS ...
1
vote
0answers
58 views

How to delete a point with known coordinates in python?

I was wondering if there is a piece of code that does the opposite that setGeometry does and removes a point if there is one at x and y coordinates?
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 ...
2
votes
1answer
733 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
189 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
529 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
265 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
135 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
173 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
117 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
114 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
629 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
976 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
403 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
280 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
534 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
2k 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
1k 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
245 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
170 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
139 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
153 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
142 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
419 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
214 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
125 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 ...
3
votes
1answer
284 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
565 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
422 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
255 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
620 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 ...