Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
9 votes
3 answers
4k views

What are QGIS equivalent functions for ArcPy's Update/Delete Row/Field?

I am trying to reprogram some scripts from ArcPy to QGIS (1.8 or 2.0) and there are some simple functions that I want to be able to redo but unfortunately documentation in QGIS is lacking in certain ...
user avatar
  • 583
9 votes
3 answers
9k 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 ...
user avatar
  • 621
4 votes
0 answers
376 views

PyQGIS joining a dbf to a shapefile [duplicate]

I am trying to join a shp and dbf file using the PyQGIS API. The code I'll use is below: from PyQt4.QtCore import * vector1 = QgsVectorLayer("path to dbf file", "test1", "ogr") id1 = vector1.id() ...
user avatar
  • 101
2 votes
1 answer
881 views

Connect not working for custom QGIS form

I have a custom form for editting feature attributes. However, I can't seem to correctly disconnect and reconnect certain bindings. The init code is below and should work for any simple QT widget with ...
user avatar
  • 661
9 votes
1 answer
3k views

Programmatically associating layer with custom UI using PyQGIS?

I know it is possible to associate a layer with a custom UI for editing feature attributes using the QGIS interface. But is this possible with Python? This link shows how to achieve the result ...
user avatar
  • 661
2 votes
2 answers
4k views

How to create a polygon feature using Python?

I'm making a plugin for Quantum GIS in python. I have a polygon layer and want to create a new feature. So far, I have this because I need a polygon geometry to add the feature: surface = ...
user avatar
  • 159
6 votes
0 answers
2k views

PyQGIS CRS on the fly reprojetion [closed]

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 ...
user avatar
  • 101
5 votes
1 answer
1k 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 ...
user avatar
3 votes
1 answer
2k views

Referencing layer in table of contents using PyQGIS?

I'm trying to create a plugin for QGIS using python, But need some help. I want to 1.Zoom to a layer and 2. make the layer visible(switch off or on). But I have managed to zoom to an active layer by ...
user avatar
  • 155
13 votes
2 answers
7k views

Adding layer group using PyQGIS? [closed]

How can I create a new group in the layer manager using python code?
user avatar
  • 159
1 vote
1 answer
2k views

Problem with encoding UTF-8 chars in Windows with PyQGIS

I have the problem to show characters (äöü) in a utf8 format in Windows. In Linux there is no problem and everything is displayed correctly. I use at the second line: # -*- coding: utf-8 -*- and ...
user avatar
  • 2,818
17 votes
3 answers
9k views

Zooming to selected feature using PyQGIS

I want to create a function that selects a feature and zooms to it (similar in QGIS). Therefore there is following function: QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) def zoomTo(self): ...
user avatar
  • 2,818
0 votes
1 answer
2k views

How to read attributes in pyQGIS and QGIS 1.8 without setSelectedFeature

I add a vector layer to a map with QgsMapLayerRegistry.instance().addMapLayer(self.vlayer) later the attributes are read with def select_all(layer): layer.select([]) layer.setSelectedFeatures([obj....
user avatar
  • 2,818
2 votes
1 answer
509 views

How to get mean of pixel values within a buffer zone around current mouse position in QGIS

for a qgis 1.8 python plugin I want to query the mean of all pixel values of a raster layer within a defined buffer around the current mouse position, not for an existing point layer. For the buffer ...
user avatar
  • 377
0 votes
1 answer
150 views

How can i detect the number of polygon is drawed in a edit session in QGIS

I am working with qgis 1.8 and i want to know how many polygon drawed in one edit sessions is there any signal emitted with qgis ???
user avatar
4 votes
1 answer
5k 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). http://hub.qgis.org/wiki/quantum-gis/...
user avatar
  • 7,920
7 votes
2 answers
1k views

Why does QgsSpatialIndex.nearestNeighbor(point, 1) sometimes return 2 lines?

I'm trying to get the closest line to a point using PyQGIS in a plugin. The active code file is this: http://pastebin.com/TDzmsKVM When I request the closest line (only 1) nearestIds = self.spIndex....
user avatar
7 votes
1 answer
1k views

How to load the layer style from PostgreSQL with Python

I would like to write a Python macro that upon opening my QGIS project file will reload the default style for each layer from the PostgreSQL 'layer_style' table. I have had a look at the documentation ...
user avatar
  • 2,616
2 votes
2 answers
4k views

How to draw a Circle of fixed radius in QGIS using QgsMapCanvasItem?

I have derived a class from QgsMapCanvasItem for drawing circle of some radius at a given latitude and longitude. In my paint function I am using QPainter to draw the circle as void paint (QPainter* ...
user avatar
2 votes
2 answers
2k views

Finding variables of QgsPolygon and QgsPolyline?

now I want to use QgsPolygon (and Qgspolyline,too) class in python I have a example by using QgsPoint but I don't know how to use in QgsPolygon following is my Qgspoint example feature = ...
user avatar
6 votes
1 answer
4k views

How can I create a new layer from the current selection using PyQGIS?

Is it possible to create a duplicate layer, only displaying the selection from the layer you are duplicating in QuantumGIS? Similar to ArcGIS -> Create Layer from Selected Features. I looked at "How ...
user avatar
  • 307
2 votes
1 answer
954 views

ImportError: No module named qgis.core

I am on Ubuntu 13.04. I get the following error message - Traceback (most recent call last): File "analyse.py", line 1, in <module> from log import shelve File "/home/...
user avatar
4 votes
1 answer
1k 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 ...
user avatar
  • 8,422
1 vote
1 answer
946 views

Looking for PyQGIS Syntax Examples/Guide

I am a long-time user of arcgis with intermediate experience python scripting for automation of geoprocessing workflows. I am moving towards using QGIS on the regular and I would like to dive into ...
user avatar
  • 1,139
2 votes
0 answers
441 views

Spatial Filter in Qgis Using Python [closed]

Is it possible to create buffer and get intersected features in Qgis using Python? I did in ArcObjects.but i need the same in QGIS also. Dim topo As ITopologicalOperator topo = chkPoint Dim sFc As ...
user avatar
  • 973
0 votes
3 answers
1k views

Getting error in compiling make file for plugin build in qgis 1.8

I am using QGIS 1.8 for building plugin. For developing i am using following ref this link example. where in this step 6 where compile the makefile in OSGeo4W. gives error pyuic4:command not found. I ...
user avatar
  • 610
1 vote
1 answer
78 views

Qgis 1.9 issues with python [closed]

I already installed the version 1.9 of Qgis and when i runned e Script python on i could this error 'NoneType' object has no attribute 'children' however it works fine on qgis 1.8 could someone ...
user avatar
3 votes
3 answers
2k views

How to add QGIS Python API Intellisense support in Aptana Studio3/Pydev

I'm developing QGIS plugins using PyDev in Aptana Studio 3 and I would like to know if it's possible to make it aware of the QGIS API and add some "intellisense" functionnalities when programming. For ...
user avatar
8 votes
4 answers
8k 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 ...
user avatar
5 votes
2 answers
2k views

How to add layer/raster with specific position in the QGIS layer list?

I use addRasterLayer(rast,'Name') but this adds the raster to the top. It is possible to set position when I add raster at once? Is it possible??
user avatar
  • 1,511
2 votes
1 answer
640 views

How to store attributes of a large shapefile in a list?

I am trying to store the attributes of a shapefile into a list. With following code it works for smaller shapes: addA = [] While provider.nextFeature(feat): attrs = feat.attributeMap() for (k,...
user avatar
12 votes
1 answer
7k views

Writing vector layer to CSV file with geometry using PyQGIS?

I use Python try to write vector layer file to csv file with this code: QgsVectorFileWriter.writeAsVectorFormat(mylayer, r'c:\temp\xyz.csv', "utf-8", None, "CSV") It can export to xyz.csv but only ...
user avatar
  • 121
5 votes
2 answers
4k views

Setting up Python 2.7 to work in both QGIS and ArcGIS Desktop?

I have both ArcGIS 10.1 and QGIS 1.8 installed and both include Python 2.7 in slightly different setups and in different folders (c:\Python27\ArcGIS10.1\ and c:\Program Files (x86)\Quantum GIS Lisboa\...
user avatar
11 votes
5 answers
7k views

Calculating Image boundary / footprint of satellite images using open source tools?

I need to create the polygon outlines of several single layer raster images, not the extent/bounding box, but the area without the nodata values, as shown here: Creating shapefile showing footprints ...
user avatar
  • 423
0 votes
1 answer
130 views

Make many lines in one layer (Python)

I what to create many lines with this code: v_layer = QgsVectorLayer("LineString", "cable", "memory") pr = v_layer.dataProvider() seg = QgsFeature() seg.setGeometry(QgsGeometry.fromPolyline([...
user avatar
0 votes
2 answers
129 views

Python to get ids from shapefile don't return all records

I have some Python code to get the ids and georeference from a shapefile: canvas = qgis.utils.iface.mapCanvas() allLayers = canvas.layers() nos = QgsFeature() for i in allLayers: if i.name()=='...
user avatar
0 votes
1 answer
160 views

How to convert geometry of shapefile to decimals

I try to create a line with two points. These points are obtained in a shapefile layer. How can I convert that points to decimals?
user avatar
0 votes
2 answers
2k views

How to display data from a feature?

I want to display data based on the feature currently selected/clicked on. I am following a tutorial from http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html. It initially shows you how ...
user avatar
2 votes
1 answer
1k views

How to use expression in QgsVectorlayer label by using python?

how to show the two field values as a label on features. I have done it for a field called "ErrorDescr" with this i need to show another field values. Other field is "MarkerId" layer....
user avatar
  • 973
13 votes
2 answers
16k views

How can I programatically create and add features to a memory layer in QGIS 1.9?

I had a working plugin in QGIS 1.8 which read data from an MSAccess database and added it to a series of memory layers. There is some processing involved in the interim so I don't think simply using ...
user avatar
6 votes
1 answer
4k views

Understanding QGIS API documentation to write Python code using QgsVectorLayer?

I am not sure how to use the API documentation to code in Python. For example, I want to determine whether a layer is a point, line or polygon layer and found the following in the API documentation: ...
user avatar
1 vote
1 answer
2k views

Running a script with QgsFeature from within the console

I am trying to run a script from the QGis Python console (similar to: http://spatialgalaxy.net/2012/01/27/qgis-running-scripts-in-the-python-console/) The line feat=QgsFeature() operates fine from ...
user avatar
5 votes
3 answers
6k views

How to set Marker Line symbol for QgsVectorLayer by using Python?

QgsVectorLayer Right click->Properties->Style->Single symbol->click on simple line in tree node ->symbol layer type -> Marker line Kindly help me to set marker line symbol programmatically by using ...
user avatar
  • 973
-1 votes
4 answers
2k views

How to make line with arrow head in QgsVectorLayer using python?

I need to draw line with arrow head or after drawn the line i need to make it as arrow head line by using python. or can we set any arrow head symbol for line features by using python? Kindly help me ...
user avatar
  • 973
1 vote
1 answer
870 views

Open QGIS project with parameters

I am looking at a piece of work to deploy QGIS as the standard within an organisation. There is an existing piece of software that I need to link to QGIS so that when a button is pressed within the ...
user avatar
  • 575
8 votes
1 answer
8k views

Finding nearest line to point in QGIS? [duplicate]

Given a point and few lines, how should I go about finding the nearest line to the point? I am aware of Finding nearest line to point using ArcGIS Desktop (ArcObjects/ArcPy)?, but that is in ArcGIS ...
user avatar
33 votes
1 answer
9k views

Drawing perpendicular lines in PyQGIS?

I have a situation like this: What I need to do is to connect each point to every line that is at most, let's say 200 m, away from the point. In other words, I need to draw a perpendicular line from ...
user avatar
3 votes
1 answer
3k views

How to "Merge Selected Features" with python?

I have been looking for the answer to this question for some time now, but can't seem to find it! My problem is straight forward: I have one layer It contains lots of features (only polygons), say ...
user avatar
4 votes
2 answers
4k views

Creating QGIS layers in python console vs stand-alone application

I am having trouble creating a QGIS vector layer in a stand-alone python script while exactly the same code works fine in python console inside QGIS. The following code results in a proper ...
user avatar
  • 173
11 votes
2 answers
6k views

How to automatically reload raster layers if source is changed in QGIS?

How to automatically reloaded raster layer if source is changed? (The path is the same but inside source file are changes) I use: qgis.utils.iface.mapCanvas().refresh() but layer not refresh. # #...
user avatar
  • 1,511

1
125 126
127
128 129
131