Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
15 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, ...
0
votes
1answer
15 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
41 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 ...
1
vote
1answer
24 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 ...
-4
votes
0answers
32 views

Creating Check Boxes for all the Layers displayed inside the List View

I have a List View in my UI. Inside which I would like to display the layers loaded in my QGIS toc. For each layer in List View, it should automatically create checkboxes for all layers. How this can ...
1
vote
0answers
47 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 ...
0
votes
0answers
20 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
39 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
22 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
29 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
34 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
45 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
34 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
44 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
22 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
44 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) ...
1
vote
1answer
33 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
31 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
17 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
28 views

PyQGIS - Setting Scale Dependent Visibility for WMS

This code imports 'MiniScale' mapping from my WMS miniScale = ...
0
votes
0answers
37 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
38 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
59 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
45 views

PyQGIS jump to row N

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
30 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
36 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
99 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
1answer
74 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 ...
1
vote
1answer
47 views

Plugin to run one function when run button is clicked

My plugin gui is attached below which has two functions one is selecting state, cities from the combo box and distance to be entered in the lineedit and the other is if we click a pushbutton it will ...
2
votes
1answer
43 views

Go through items in a composer legend (QGIS 2.6)

I'm trying to develop a plugin in QGIS 2.6, which opens a composer, add a map and a legend, and (among other things) adjusts the legend. Is there a way to go through items in a composer legend with ...
-2
votes
0answers
39 views

Using a QGIS tool in my plugin [duplicate]

I want to use Select Features by Freehand tool in my plugin I want to know what are the steps i should include in my code for calling and using this plugin. Like whether the code should be added in ...
0
votes
2answers
51 views

How to get a layer that is not active with PyQGIS

I want to retrieve attributes of selected objects on a layer with PyQGIS. All example I see is for the active layer: vlayer=qgis.utils.iface.activeLayer() selected_bf = vlayer.selectedFeatures() ...
2
votes
1answer
45 views

How may I use Umlaute programmatically to show up correctly in PyQGIS messagebar?

So far I couldn't figure out how to write something like u"Einstellungen aus ArcView übernehmen" to show up correctly as the titel of my messagebar. At least I can save my source (although this seems ...
0
votes
0answers
18 views

Refreshing QGIS view [duplicate]

I've written a short python script for use in QGIS (currently using 2.8.1) to set the CRS for all loaded layers to OSGB 1936 / BNG. The script correctly sets the CRS but I have to manually scroll ...
1
vote
1answer
34 views

Trouble buffering a vector layer in QGIS with PyQGIS

I am working on a script that imports a .csv layer that has lat long coordinates, which I then want to buffer in feet. I've created a vector layer from the .csv file and tried to set the coordinate ...
0
votes
0answers
25 views

How to activate the cursor once we deactivated by activating panning tool

We have activated pan tool on canvas using the following command: canvasPressEvent(self,event): if event.button == 1: qgis.utils.iface.actionPan().trigger() canvasReleaseEvent(self,event): ...
-1
votes
1answer
28 views

List printing same values as a buffer output instead printing unique values

I have a list of features selected in the mapcanvas and for that selected features i am doing buffer and printing the feature names that are inside the buffer. While printing,all values in the list ...
2
votes
1answer
36 views

How to add point features with coords taken from a .txt and show them on the map canvas?

Ok, so i am on Windows 7 and using QGIS 2.6 and i have a .txt file with some simple coords. I have extracted the coords to a list, no prob with that. But i looked at the PyQGIS cookbook on how to add ...
3
votes
2answers
71 views

How to access checked layers in PyQGIS?

qgis.utils.iface.activeLayer() accesses the current active layer, but I would like to get all checked layers in the QGIS ToC. How can I do it?
1
vote
1answer
38 views

Convexhull for selected features and performing buffer for the resultant convexhull using python

I have features selected on the mapcanvas. I want to perform convex hull for those selected features and save those in a memory or store it in a variable preferably and then want to do buffer for the ...
1
vote
0answers
40 views

How to install pygame or Tkinter for QGIS Python?

So i have downloaded pygame and installed it. Now i want to write scripts and run them through the QGIS console that implement methods of pygame but when the console reads "import pygame" i get a ...
1
vote
1answer
30 views

Save Vector layer and update .qgs project file (pyQGIS)

need help to solve the following use case: QGIS started with new project (no layers) New layer is created programmaticaly and data is populated: vl = QgsVectorLayer("Point", "temporary_points", ...
1
vote
0answers
14 views

Labels not displaying when rendering to image with pyQGIS

I'm using the simple example in the pyQGIS cookbook http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html I'm able to manipulate the features in my layer using Python, but the ...
1
vote
2answers
50 views

How to programmatically close a QMessagebox without clicking ok or X? [closed]

So part of my script in PyQGIS is this: QMessageBox.warning(None,"Warning","bla bla bla") The box apperas just fine but i want it to close after a few seconds so i am looking for something like ...
1
vote
1answer
20 views

How to apply Zoom Extent from several QgsVector layers with Labels in PyQGIS?

I have the following case: Project constists of three layers: Open Layers plugin with Google streets QGSVector layer with Point features and Label enabled QGSVector layer with Polyline features and ...
3
votes
0answers
59 views

How to stop a PyQGIS script that has an infinite loop, using the keyboard?

So i wrote a script that does what i want over and over again using a "while True:" in a certain time interval (every 5 seconds using time.sleep(5)). So far so good BUT when i want to stop it i just ...
0
votes
0answers
38 views

How to reload a raster file from the python shell

I do this in the QGIS python shell: # get the raster file (and data) of the active layer canvas = qgis.utils.iface.mapCanvas() rLayer = canvas.currentLayer() rLayerPath = ...
3
votes
1answer
64 views

How to change the edit widget for fields in a layer with PyQGIS?

Is possible change the edit widget with PyQGIS? I have made an extension that loads a PostGIS layer and I want to edit the date fields with the date widget by default without any change in the ...
2
votes
1answer
42 views

Why this Python script only works once on QGIS?

So i have this script to change the color of some specific features(lines) using categories in a vector layer. When i import the script the console in the first time through the console it works just ...
1
vote
1answer
25 views

QGIS get the X and Y of a raster file by click

I have a raster file (Geotiff) and try to write a plugin that can change the value of one cell in a raster (== array cell). I know how to get a QGIS point but how can I get the array index from on ...