Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
8 votes
2 answers
6k 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 ...
alex's user avatar
  • 103
17 votes
4 answers
17k views

Buffering 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 ...
GIS Danny's user avatar
  • 733
3 votes
1 answer
2k 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 ...
GreyHippo's user avatar
  • 2,210
1 vote
1 answer
404 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 = ly....
klausb's user avatar
  • 75
7 votes
1 answer
2k 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.
Justin's user avatar
  • 71
9 votes
1 answer
4k views

Calling 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 modules. ...
MarieA's user avatar
  • 91
4 votes
1 answer
2k 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 successful with that.
klausb's user avatar
  • 75
11 votes
5 answers
37k views

Fixing "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 ...
Pedro Camargo's user avatar
2 votes
1 answer
1k 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 ...
J_L's user avatar
  • 99
2 votes
0 answers
169 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.6.5 ...
Roman Bekkiev's user avatar
9 votes
2 answers
12k 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?
GreyHippo's user avatar
  • 2,210
6 votes
4 answers
2k views

Iterating over selected layers using PyQGIS

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 an iface.selectedLayers() but I can find only iface....
user10138's user avatar
3 votes
3 answers
1k 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 ...
Jayden's user avatar
  • 700
2 votes
2 answers
790 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. ...
rpet's user avatar
  • 159
4 votes
1 answer
896 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 ...
Jayden's user avatar
  • 700
1 vote
0 answers
631 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() ...
rpet's user avatar
  • 159
1 vote
0 answers
125 views

Adding dialog and classes to QGIS plugin [closed]

What are the steps to add files that represent a uidialog(draw with QTDesigner), and add the necessary python class files, using the default makefile provided with qgis plugin builder?
Arthur Portas's user avatar
6 votes
1 answer
3k views

Get extents of vector shape features in PyQGIS?

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 PyQgis-...
Curlew's user avatar
  • 8,180
9 votes
1 answer
2k views

Listing installed QGIS plugins via PyQGIS

Can you please tell me how I can programmatically (or from the console) access the loaded plugin list? I tried: QgsProviderRegistry.pluginList() but got: TypeError: QgsProviderRegistry.pluginList(...
Petros Apotsos's user avatar
4 votes
1 answer
3k views

Creating Selection MapTool in PyQGIS Custom Application

I'm developing a custom GIS application using the 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 ...
Karthik Bharadwaj's user avatar
8 votes
1 answer
3k views

Adding calculated fields with PyQGIS

In the Memory provider described in PyQGIS Cookbook and in the question Creating new empty vector layer with PyQGIS I can see how to create a Vector Layer programmatically using standard fields (...
rpet's user avatar
  • 159
2 votes
2 answers
4k 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 ...
HeyOverThere's user avatar
  • 7,873
7 votes
4 answers
11k views

Linking to external files with relative path in QGIS actions

Objective: I have point layers with attributes that contain paths to external files (Visio, AutoCAD dwg...). I want to put them all in one folder together with the project file, compress the folder ...
Cao Minh Tu's user avatar
  • 2,024
27 votes
5 answers
25k views

Getting path of 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?
fccoelho's user avatar
  • 1,247
2 votes
0 answers
705 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 QtSql(tested ...
Arthur Portas's user avatar
1 vote
0 answers
302 views

SVG markers with PyQGIS [closed]

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...
Ulf's user avatar
  • 41
11 votes
2 answers
11k views

Getting projection from vector layer in QGIS

I am trying to set the projection on a raster to match that of a vector point layer. Thus I need to find out what is the projection of a given layer, to use it in the GDAL.Dataset.SetProjection() so ...
fccoelho's user avatar
  • 1,247
10 votes
1 answer
4k views

Creating raster layer from 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 ...
fccoelho's user avatar
  • 1,247
2 votes
0 answers
903 views

Accessing MySQL data from python built-in console of QGIS?

I'm writing a QGIS Plugin, and somewhere I want to present data from a MySQL database. It's simple data(strings,etc), not Geospatial, or vector data. I'm familiar with querying databases from python ...
Arthur Portas's user avatar
2 votes
3 answers
2k views

Merging large amount of polygon-features in script with GDAL/OGR Tools or Python?

We have a very large shapefile with over 30000 features and want to merge it with a script on a server. Currently we try it with QGIS, but the processing takes way too much time. Is there a way to do ...
leak_my_brain's user avatar
4 votes
1 answer
8k views

Loading feature (.qml) styles from PyQGIS [duplicate]

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 categories and symbols needed, but I can not find the right function to ...
greenland's user avatar
1 vote
0 answers
320 views

QGIS and embedded ajax (Bing Map) [closed]

I need to load in a docked QWebView this html: < html > < body > < iframe width="100%" height="499" frameborder="0" scrolling="no" ...
user10138's user avatar
2 votes
1 answer
515 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 ...
userHH's user avatar
  • 205
4 votes
1 answer
4k views

Splitting 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: some_line....
SS_Rebelious's user avatar
  • 5,621
18 votes
3 answers
17k views

"Select by Attribute" in QGIS using python?

Is there a way to use the function "Select by Attribute" in QGIS using a python command? In my plugin the user should enter a value via a GUI and this value should be used in a function which selects ...
userHH's user avatar
  • 205
11 votes
3 answers
15k views

Getting attributes of selected features using PyQGIS

Could anybody provide an example how to get the attributes of selected features? I tried the following code in the Python Console : but I'm stuck at the point where I'd like to get the attributes: ...
dimpflmoser's user avatar
3 votes
2 answers
6k views

Setting color of feature depending on attributes with PyQGIS?

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?
Ulf's user avatar
  • 41
2 votes
1 answer
896 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 ...
klausb's user avatar
  • 75
5 votes
1 answer
4k 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, ...
CPBL's user avatar
  • 280
2 votes
1 answer
4k views

Implementing signals on add or modify feature using PyQGIS

I've created a test plug-in in QGIS successfully but have had a hard time implementing a signal on a vector layer event (add or modify feature). I've added this to my initGUI method: QObject.connect(...
user9515's user avatar
11 votes
3 answers
19k views

Obtaining the data of one selected feature in QGIS using Python? [closed]

Is it possible to get the data of one selected feature in QGIS using Python, and if so how? In my example I have a layer which shows some parcels for urban planning. If I now select one of the parcels ...
Sven's user avatar
  • 822
10 votes
1 answer
7k 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 = vlayer....
Cyrus's user avatar
  • 1,498
14 votes
2 answers
5k views

Adding toolbar via PyQGIS?

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?
dimpflmoser's user avatar
3 votes
0 answers
751 views

no module named core

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 been ...
Becky's user avatar
  • 637
31 votes
3 answers
29k views

Creating new empty vector layer with PyQGIS

I have looked at a few tutorials on Python scripts for QGIS. All of them create new vector and raster layers with some existing data source e.g. shapefile or GeoTIFF or PostGIS database table. Is it ...
Theuns Heydenrych's user avatar
4 votes
1 answer
3k 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) ...
Massimo's user avatar
  • 41
4 votes
0 answers
2k views

Changing feature's geometry?

I'm creating my layer like this: crs = core.QgsCoordinateReferenceSystem(4326, core.QgsCoordinateReferenceSystem.EpsgCrsId) uri = "Polygon" uri += '?crs=' + crs.authid() uri += '&field=id_tsk:...
Djabx's user avatar
  • 285
1 vote
1 answer
1k 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 ...
user8790's user avatar
1 vote
1 answer
89 views

Which class to work with vector layers using PyQGIS?

I'm doing different operations on vector layers. Which class should I use for vector layer i.e QgsVectorLayer or QgsVectorLayerDataProvider?
M.Umair Khan's user avatar
2 votes
1 answer
2k views

Importing QGIS core into Python on OSX

I am interested in learning how to write standalone scripts using QGIS. An answer to my previous question directed me to the PyGIS CookBook which has the following instructions for importing the ...
djq's user avatar
  • 16.3k