Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
1answer
43 views

pyQGis scale based visibility problem

Im loading some layers from postgis using pyqgis in my standalone qgis app. For each layer i also load a style using: lyr.loadNamedStyle("style.qml") I've setup 2 versions of styles in qgis ...
2
votes
1answer
52 views

PyQGIS: subtracting two values and append ID to list

I would like to subtract two values retrieved from qgs feature iterator objects and append the value of the feature id to a list depending on a condition. I have two layers: roadsLayer pathsLayer ...
1
vote
1answer
52 views

How to remove a layer and its legend in a standalone pyqgis application?

In continuity in my question "How to add a legend to a canvas in a standalone PyQGIS application?" > In every addition of a new layer in my standalone application, the legend lengthens and becomes ...
1
vote
0answers
28 views

PyQGIS - Syntax for importing WKT file

I couldn't find any proper example of how to import a .csv with WKT coordinates (Polygon) in PyQGIS. Here are more details on my .csv. I am working with polygons. The delimiter is a semi colum, and ...
0
votes
1answer
35 views

Problem calling qgis2leaf outside the QGIS

I am a computer programmer starting with PyqGis-Python, and I’d need to automatize the creation of a webmap using the plugin of qgis2leaf from a QGIS Project. I have reached to call “import ...
0
votes
0answers
21 views

Multi Label with Multi Placement

is there any way to add multiple label at different placement in qgis. Suppose I have a vector layer for line geometry and my attribute are name and route number. Now i want to add the route number to ...
2
votes
2answers
134 views

How to use `layer.getFeatures()` in a standalone script?

I am following the QGIS Cookbook and this post where it concerns reading attributes from layers. I would like to exploit this method and implement it into a standalone script. Essentially, I want to ...
2
votes
1answer
52 views

use gdal python bindings from the QGIS folder in a custom script

I have QGIS installed (on Windows) and can import this line from the QGIS Python console: from osgeo import gdal When I try the import in a python file it doesn't work Traceback (most recent call ...
1
vote
0answers
94 views

Buffer Csv gets repeated when more than one feature is selected in mapcanvas in PYQGIS

I have a function which will allow the user to select a feature or more features in map canvas and performs buffer for the selected feature(s) and writes the output to a csv file. I dont have any ...
3
votes
2answers
150 views

How to add a legend to a canvas in a standalone PyQGIS application?

I am trying to develop a standalone PyQGIS application. The map display does not pose any problems, but I do not know how to add a legend to the canvas.
1
vote
1answer
70 views

How can I get features that satisfy a QgsExpression using PyQGIS?

I have two fields say "State" and "name" which would be get from the two comboboxes. After which, based on the current text in the combo box, I want to make QgsExpression and feature that satisfies ...
0
votes
1answer
52 views

How to access shapefile m-values with pyqgis?

Does anyone know how to access (read/write) m-values of a line-shapefile using pyqgis? I know how to do it with arcpy cursors ...
0
votes
0answers
43 views

Is PyQt4 'drag and drop' functionality available in Qgis Plugins?

In Qgis 2.8, is it possible to use the PyQt4 drag and drop classes (dragEnterEvent, dropEvent) to interact with items from a qtreeview, in a Python Plugin? Is it possible to hook into the ...
1
vote
1answer
46 views

How to implement Add feature action from PyQGIS

I'm trying to implement / reuse Add Feature functionality in my python plugin. there a class/function that handles geometry creation on canvas based on layer geometry definition? I'm checking API but ...
1
vote
2answers
92 views

How to install 3rd party python libraries for QGIS on Windows?

How can I use 3rd party libraries on QGIS plugins on Windows? I've developed a plugin that uses rasterio and numpy for a customer, but he's having problems installing rasterio and numpy. Actually ...
2
votes
1answer
137 views

Select by location in Python

I have a polygon layer and a point layer (with coordinates for each point). The polygon layer got created using the MMQGIS PlugIn (Hexagonal Polygons). I want to select all the points inside each ...
3
votes
2answers
108 views

Using folder wildcards to copy files with Python

I would like to copy the data of one specific shapefile from a specific folder ("Grid") to a number of folders containing the name "Country". The country shapefiles would keep their original name. ...
0
votes
2answers
70 views

Extract Elevation of Points from DEM using Python QGIS or GRASS

I am utterly new to GIS, so please bear with me if I am providing incomplete information here. I have a DEM file (.dt2). What I am looking to do is as follows: take a series of points specified as ...
2
votes
1answer
56 views

Not able to load any Raster File using QGIS Python

I am trying to run an elementary piece of Python code, that simply loads a dem file as a raster accessing the QGIS Python API. On the embedded console (within the QGIS application GUI), it runs fine ...
1
vote
1answer
34 views

Rename output shapefiles in PyQGIS

I have a shapefile which resides in a folder, gets processed and the output is saved in another folder. Before the output, I would like to rename the shapefile slightly differently from the original: ...
0
votes
1answer
55 views

polygonize giving duplicated polygons

I am trying to reproject some ascii files and convert them into shapefiles. I am new to python but looking at some code online and help files I was able to write the following code to run on Python ...
0
votes
1answer
45 views

Script not processing shapefiles from one folder to another

I am working on a script which takes shapefiles from one folder called "Original files", process them and then output the results into another folder named "Processed files. I asked a question on how ...
1
vote
1answer
88 views

differences in distance between shapely and geopy

I am getting totally different distances from shapely and geopy. On one hand - it makes total sense, shapely measures on a plane and geopy measures on a spheroid. But the differences are so dramatic, ...
1
vote
1answer
48 views

Rename layers with script

Just discovered Qgis and really impressed! I've not formal GIS training so rely on Google to figure stuff out. I'm using the SHP files made available by the Canadian Government as part of their ...
1
vote
1answer
111 views

Where is the python library of QGIS 2.8

where is the Python library for QGIS 2.8 on a mac (10.10)? I cannot find it... sys.path in the QGIS python console gave me some path, but where the interesting part is happening it replaces the ...
3
votes
1answer
173 views

Programmatically grouping multiple layers into separate groups using QGIS?

I'm trying to group a large number of layers together based on a common portion of name string. They are a mix of polygons and points. I would like to create individual groups by using part of the ...
1
vote
1answer
55 views

Multi-Ring Buffer Methodology

When creating a multi-ring buffer I see two methodologies: Create buffer around feature, buffer the resulting buffer, and repeat for as many rings as required. Using the initial feature to create ...
1
vote
0answers
115 views

Qgis 2.6 and 2.8. Custom form and Init function

I try to apply the good tutorial written by Nathan "Custom feature forms with Python logic". I try his sample on qgis 2.6 and 2.8. I altered the sample to allow field initialization by setting ...
1
vote
0answers
36 views

Reading/writing utf-8 encoded data using Fiona?

So I have a 'cpg' file with my 'in_file' shapefile data (definitely set to 'utf-8'). I was using 'meta' to create the same schema/crs as 'in_file'...though it runs, my text fields are borked on ...
0
votes
1answer
62 views

Problems with Geometry collections. (Fiona: write output of Multipoints and Points)

Updated: I am getting the following error on this function: ValueError: Record's geometry type does not match collection schema's geometry type: 'Point' != 'MultiPoint' The problem is that I have ...
1
vote
1answer
38 views

Can you change the layer name of an output vector from a processing script in QGIS?

I define an input csv file and an output like so in my processing script: ##Input_CSV_File=file ##Output_Shapefile=output vector The output shapefile is added to the map automatically when the ...
1
vote
0answers
40 views

Something changed in QgsVectorDataProvider().changeAttributeValues() in QGIS 2.8?

I have a plugin that works with QGIS 2.2 but does not work with 2.8. Only deleteFeatures() works fine, but changeAttributeValues(), changeGeometryValues() and addFeatures() not. I receive r == False ...
1
vote
2answers
46 views

Writing PyQGIS Output to Shapefile

I'm trying to find the closest point on a line to another point as in this post. However when I try to write the result as a shapefile I get an error: TypeError: ...
0
votes
2answers
70 views

How to measure distance using shapely

Reading the documentation...it looks like I should have this right, but I don't. The example is: Point(0,0).distance(Point(1,1)) 1.4142135623730951 Based on this example I wrote this block ...
1
vote
0answers
60 views

While loop in QGIS modeler

I am looking for a way in QGIS - preferably using the graphical modeler but console scripting will also do - to build a model that iterates through features of a given layer until a condition is met - ...
1
vote
1answer
51 views

How to call 'shapely' .coords on a fiona filtered list?

I have to filter a shapefile by attribute then compare it to another shapefile using .coords...however I am a bit perplexed how to do this as my filter is returning a list type...(and .coords requires ...
0
votes
1answer
31 views

Behaviour of Select Feature by Freehand tool in my own plugin

I am calling QGIS "Select Feature by Freehand tool" in my plugin. what it will does is it allows the user to select features in mapcanvas and i made a signal like if selection changed in mapcanvas , ...
1
vote
1answer
47 views

No expected output when accessing variable from one function and using in another fucntion

I have a function say selectedfeatures this function would be called when a selection changed event happens in mapcanvas. self.canvas.selectionChanged.connect(self.selectedfeatures) ...
2
votes
1answer
63 views

How to define an event for features selected in mapcanvas in qgis using python

I have created a push button, when it is clicked it calls the function 'selectfeatures'. This function will call the Select feature by free hand tool of QGIS and allows the user to select features in ...
1
vote
1answer
75 views

How to replace VectorWriter with QgsVectorFileWriter?

Within QGIS 2.8.1 I found within the Processing Toolbox a script called "Points on crossing lines" which should exactly as it is named. Unfortunately it needs processing.core.VectorWriter which I ...
1
vote
0answers
22 views

QGIS plugin : connect to polygonselect Maptool signals

Working on a new plugin I am trying to connect a custom function to the mouse right-clic signal while using the polygon selecting maptool. I have activated the maptool through : def run(self): ...
1
vote
1answer
52 views

Setting Scale Dependent Visibility for WMS in PyQGIS

This code imports 'MiniScale' mapping from my WMS miniScale = ...
0
votes
0answers
45 views

How to store a triggering action and events and call them when needed using python in qgis

Can anyone explain in detail how to store the triggering action or an event that take place in the mapcanvas in a variable and call the same when needed in python. Say for example,say i have ...
2
votes
1answer
62 views

How to import the “QGis” class in a script?

I want to check which type of geometry the current layer has. Therefore I use the PyQGIS documentation on Access to Geometry and my code looks like: if iface.mapCanvas().currentLayer().wkbType() == ...
2
votes
2answers
75 views

Is it possible to sort the features by an attribute programmatically?

I have written a PyQGIS script that loops through an attribute table and finds duplicated values in a target attribute field. My technique requires that the attribute table is first sorted by the ...
2
votes
1answer
67 views

How to access a specific feature?

Is it possible to go to a specified row number (or perhaps the next/previous) row using PyQGIS? This code gets the value of the first attribute in the first row of the table features = ...
1
vote
1answer
34 views

Initalize plugin with current working directory?

Upon starting Qgis, a (currently under construction) plugin needs a means of checking the current project/legend/registry. This checksum would ideally occur upon startup automatically. As the plugin ...
2
votes
1answer
57 views

PyQGIS: Is it possible to replace an action triggered script by one supplied through a plugin?

In ArcView 3 all controls (menu choices, buttons, tools) had scripts associated with them that could be changed simply by supplying a script with the same name through an extension (plugin). That way ...
2
votes
2answers
125 views

Batch add column to layers and add layer prefix in PyQGIS

I have a number of layers each with a prefix like A_ B_ and so forth. I'd like to: Add a column (text) called DENSITY to each shp Add the prefix letter from the layer name to each row in the ...
1
vote
2answers
175 views

“ImportError: no module named qgis.core” in standalone app

I am developing a standalone app (in Windows) using libraries from QGIS. When I run the script in cmd, I get the ImportError: no module named qgis.core. I read in several posts that I need to ...