Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
1answer
126 views

How can I modify layer order with the QGIS python API

Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it? I use an existing QGIS ...
4
votes
1answer
294 views

How to write scripts that can call on both Arcpy and PyQGIS?

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
4
votes
0answers
53 views

Using QGIS plugins from Python [duplicate]

Is there a simple way to automate calls to QGIS plugins from a QGIS Python script? Either from console or a plugin? I am ideally looking for a way to specify input/output parameters and bypass GUI. ...
4
votes
0answers
271 views

PyQGIS CRS on the fly reprojetion

As a first step of a pyqgis plugin I'm trying to import several shape files at once. To get them aligned, using the GUI, I'd enable on the fly reprojections and set the project crs to WGS84. I'd then ...
4
votes
1answer
288 views

QGis Zonal Statistics Plugin NoData included in Calculations

I have been trying to use the QGIS zonal statistics plugin. My raster has a nodata value of -99999 and all other values are positive. After computing the mean zonal statistics there are a number of ...
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
727 views

Get a pixel value

How can i do this operation: I want to get a pixel value fro the satellite image (Landat, GeoTIFF, 7 bands) using qgis-python. What operators should i use? (for example in qgis's Python Console) ...
3
votes
3answers
526 views

How to find the polygon inside which a point lies?

I have a layer with polygonal features. Each feature has attributes and values. I also have a list of co-ordinates and I would like to know which feature (or polygon) the co-ordinates lie in. Could ...
3
votes
2answers
203 views

How to write an equivalent to MapBasic's CreateLine in pyQGIS?

I know this kind of question has been asked, in part, before - specifically: Seeing QGIS Python Commands and: How is object created as line using createline stored in .tab file? but this is a specific ...
3
votes
1answer
523 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
2answers
1k views

How can I specify the CRS of a raster layer in pyqgis?

I manipulating netcdf raster data from the QGIS python console. The metadata of my netcdf file does not provide the Reference system. However I know it is 'EPSG:4326' I am writing a python script to ...
3
votes
1answer
218 views

How to apply a color gradient to a shapefile from QGIS console?

Anyone knows how to do a color gradient from the console to a shape file in Qgis (orin Python)? Like the image below.
3
votes
1answer
339 views

How to generate a grid programmatically in Python without GUI?

Is there a QGIS Python binding for generating a grid programmatically without using the GUI?
3
votes
2answers
504 views

How to get field names in pyqgis 2.0

I am trying to change an plugin from QGIS 1.8 to 2.0. In the 1.8 version I create a table of the field names like this: layer = vlayer provider = layer.dataProvider() feat = QGSFeatrue() allAttrs = ...
3
votes
1answer
205 views

How to programmatically detect a canvas refresh or pan/zoom in QGIS

For my python plugin I would like to remove a VertexMarker when the user pans/zooms there map. Which is the best way to detect a canvas refresh or pan/zoom carried out by the user? Can you suggest ...
3
votes
3answers
1k views

QGIS 2 Python error on Mac OSX

Have just installed newly released QGIS 2.0. I installed the gdal package available at the official kyngchaos site. It seems to run ok, but when the program loads up I get a lengthy error message ...
3
votes
2answers
632 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?
3
votes
1answer
1k views

How to use gdal_contour in QGIS Python console?

Is there a way to use the gdal_contour utility with-in the python console of qgis ? Thank you
3
votes
2answers
964 views

Standalone applications using QGIS and environment variables

I've tried going through IRC to see if people can help me out with this, but the medium seems a little clumsy for making any answers clear, so I'm going to try this instead. I would like to program a ...
3
votes
1answer
700 views

How to find the nearest line to a point in QGIS? [duplicate]

My question is that given a point and few lines, how should I go about finding the nearest line to the point? I am aware of How to I find the nearest line to a point?, but that isin ArcGIS and ...
3
votes
1answer
323 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 ...
3
votes
1answer
138 views

Looking for help for automatically making a QGIS map

Im looking at making a standalone script, that on execution will run the QGis MapComposer using a previously generated template and output a PDF/PNG of the map. This process of making a map will be ...
3
votes
1answer
314 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 ) ...
3
votes
2answers
818 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 = ...
3
votes
2answers
160 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 ...
3
votes
1answer
255 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.
3
votes
1answer
594 views

Changing attribute data types using PyQGIS

OK, so I've already asked a question how to access attribute data types when developing plugin for QGIS, using PyQGIS. And one helpful member said i should use pendingFields() method on the current ...
3
votes
1answer
39 views

How to store the CHANGES to a map database

I'm looking into providing a map amendment service for a particular map series. The service will help map owners look into the changes made to the operational features of the map, after the map was ...
3
votes
1answer
121 views

Get features in order they are selected using QGIS

Is there a way of establishing the order that a user selected features using QGIS and Python? By example: we have a network of line features representing a road network, and the user defines a route ...
3
votes
1answer
473 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 * ...
3
votes
1answer
129 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 ...
3
votes
1answer
352 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 ...
3
votes
1answer
283 views

How to move Layer to back?

from my Plugin I've loaded a rasterlayer using the following code: fileName = "/path/to/raster/file.tif" fileInfo = QFileInfo(fileName) baseName = fileInfo.baseName() rlayer = ...
3
votes
2answers
142 views

How can I read the settings for the QgsPaperItem from XML?

I saved a template qpt for the map composer and now I want to read all the settings. I am able to insert the items with composition.addItemsfromXML... But this doesn't load the settings for the ...
3
votes
1answer
149 views

How to set and configure a value relation edittype in QGIS 2.0?

I am trying to set the edit type of a vector layer to use a value relation. The Python commands below are processed without errors or warnings, but the when I check the properties in QGIS, only the ...
3
votes
1answer
466 views

Add attributes to vector layer with pyqgis (QGIS 2.0 API)

i am trying to make a QGIS plugin ready for the new QGIS API in the current development branch (for the upcoming QGIS 2.0 release). ...
3
votes
1answer
143 views

How to see print commands through Python Script while programming plugin for QGIS?

This might sound like a silly question. Is there a way that from running a custom plugin made for QGIS that a Python Shell can appear along when the plugin is run, like a debug screen. I'm asking ...
3
votes
1answer
454 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.
3
votes
1answer
230 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 ...
3
votes
1answer
458 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 ...
3
votes
1answer
1k 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 ...
3
votes
1answer
146 views

How to display a particular area?

Hy, I'm developing a plugin in python for Qgis. I would like the user to select a particular area in a list (let say a country list) and zoom in the map on the corresponding area. Actually I'm ...
3
votes
1answer
174 views

Load and display a layer using PYQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
3
votes
2answers
342 views

Rendering and Labeling Shapefile with PyQGIS

I've been running into a few problems working with the QGIS API for python. I've gotten more comfortable working in the python console in QGIS but I run into problems when I try to run the code ...
3
votes
1answer
768 views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
3
votes
0answers
155 views

How to create a line layer which connects a point layer to a line layer?

In the map shown below, I have manually created the dummy lines (in green). Using python, and without using PostGIS or sextante, I would like to automate the creation of these dummy links between a ...
2
votes
1answer
166 views

How to get a message when the map is moved in QGIS?

I want to get a message when every time I move the map. I had: def info(self): QMessageBox.information( self, self.tr( "Info" ), self.tr("info") ) I suppose that used to be something like ...
2
votes
1answer
816 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 ...
2
votes
2answers
2k views

How to access attribute data type in QGIS?

I've been developing a plugin on QGIS platform using PyQGIS. So far plugin does the following: You can select any feature of the already loaded vector layer in QGIS. After selection, plugin displays ...
2
votes
2answers
665 views

how to for loop a folder to batch clip rasters by polygon using python and QGIS

I am using python and QGIS 2.0. I am trying to clip rasters in a folder by one polygon feature. It's the first time for me using (let's say) "PyQGIS", I was used to arcpy before. Anyway, I don't get ...