Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
2answers
51 views

Can't render my own map canvas

My goal is to make a standalone application using the QGIS library, but for now I'm trying to make everything work in a Qgis plugin. I need to create a map canvas inside my plugin window. There is ...
0
votes
0answers
11 views

pyQGIS - hide loading gml dialog

Using pyQGIS, is there a way to hide the loading gml dialog when making WFS http requests via a plugin (for QGIS versions >2.4): After running this statement the load dialog shows: ...
1
vote
1answer
20 views

How to load the only selected features from the layer in postgresql to Qgis canvas

I am using the uri to load the layer from the postgres to qgis canvas but it is not loading the selected features without where condition it is loading the lAYER. canvas = ...
1
vote
0answers
77 views

Use cython in QGIS?

I've wondered for some time how to use Cython in QGIS. I know I can integrate a Cython code in python, but I want Cython to handle QGIS classes. QGIS is built upon QT, every qgis object is a qobject ...
1
vote
0answers
22 views

QGis through python script : no map exported (map will be printed here)

I am very new to GIS in general and even more to QGis. I have a pretty simple task which is to import all shapefiles in one folder, style them and finally export them. I have wrote python code that ...
1
vote
1answer
24 views

PYQGIS Layer to KML?

I am aware that it is possible, in QGIS, to save your Vector Layer as a KML file manually, however, I want to know if there is anyway I can do this programmatically from an external Python Script that ...
4
votes
2answers
136 views

Programmatically finding polygons which are >90% overlapped by another vector polygon layer using QGIS?

I'm trying to figure out how to use python to extract the polygons in one vector that are overlapped by >90% by another vector. I would then like to have a vector/map that will only show those ...
3
votes
1answer
34 views

QGIS QImage, can't specify a specific path

I'm a newbie in QGIS and I have to write a small python script to automate shapefile loading, applying style and save image. I'm having trouble on this last item. Here is the thing: ...
1
vote
1answer
212 views

Setting transparency of layer group with Python in QGIS?

How can I set the transparency for all layers within a group of layers? I assume this will require the use of a FOR loop in the Python Console. Based on How to set the transparency for multiple ...
0
votes
0answers
20 views

Faulty behavior after a cut operation

Short explanation of my problem: On the picture two polygons are shown. The highlighted (yellow) polygon is above the green polygon. Now, two operations are performed. ...
1
vote
2answers
33 views

How to optimize QgsFeatureRequest with filter expression

I have a point PostGIS layer (my_layer) which has more than 66000 features. I am getting the features I want but it takes too long. My code is: resultList = [] req = ...
1
vote
0answers
31 views

How to set “draw line inside polygon” using Python?

In the QGIS properties of a layer I want to activate "draw line only inside polygon" for a specific layer, but using Python. I don't want to use the GUI for it. Can this be done? I set the line ...
2
votes
1answer
74 views

Customising QGIS Map Composer default output directory and file name suffix?

I am using QGIS for map making , I am adding multiple vector and raster layers and then finally for map making I am moving to the map composer. When I am exporting the map from Map composer , I want ...
8
votes
2answers
2k views

How to add a toolbar via python?

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? ...
2
votes
2answers
53 views

How can I add a second Toolbar Button and Dialog to a QGIS plugin built with Plugin Builder?

I want to create a toolbar with 2 buttons, each button opening a different form. The steps I followed are: Created a plugin using Plugin builder Created a toolbar with 2 buttons by doing the ...
4
votes
3answers
141 views

Is there a way of labeling the number of points with the same coordinates?

After reading through the following question (which is kinda related but not quite what I need): How can I show points on the same coordinate as e.g. a bigger symbol in QGIS? I found out that there ...
8
votes
1answer
536 views

Is it possible to have dynamic layer names in QGIS project?

I have a QGIS project with layers, based on PostGIS SQL queries that use current date. Since the data in the database changes, these queries return different data every new day. Is it possible to ...
3
votes
0answers
42 views

QGIS canvas refresh & rendering control from plugin?

Plugin Description I have been working on a plugin which essentially doing the same as "GPS information" live tracking but with capability of displaying two GPS streams. I am comparing streams and ...
3
votes
1answer
87 views

QGIS Select overlapped feature

I have points that are not equal but the distance between them is so small that it can't be seen even at scale 200k:1. I calculated the distance between these points and add it as attribute. Now I ...
3
votes
1answer
510 views

Export several files at the same time in QGIS

I have a lot of .TAB files open in QGIS and I want to save them to .SHP so I can work with them in ArcMap. Is there a way to save/export all these files at the same time or do I really have to "save ...
2
votes
1answer
37 views

How do I change the pixel values of raster data from QGIS python plugin

I have been trying my hand at a QGIS plugin. The plug in reads raster layer data into an array, pipes the data to a C++ program, does processing over there, and pipes my results back. After a couple ...
2
votes
2answers
42 views

using PyQGIS to subsample a region of a raster layer's pixel data

I am having trouble sampling multiple pixels from a raster layer at oe time. If I want to sample pixel data from a layer at a particular coordinate I can write. ident = ...
5
votes
1answer
74 views

Keep UI Settings for a QGIS plugin

I'm writing a plugin that interacts with external software (hydrological models). One of the dialogs has a lot of entries (parameters to pass to the hydrological software). Once the user has set up ...
1
vote
1answer
21 views

How to integrate Live layer effect in QGIS 2.10 with the help of python code based automatation process?

I need to work with live layer effect (blur, outer glow, shadow) etc . I know how to use this with the help of QGIS symbol tool. But i need to integrate this in to my python automated map generation ...
2
votes
1answer
124 views

pyQGIS changing Paletted Raster Layers to Grayscale

I've written a plugin which imports a number of colour geoTifs (map tiles) and works correctly but it would be great to display these as Grayscale after loading in. The geoTifs load as paletted ...
2
votes
1answer
58 views

How to refresh MapCanvas while PyQGIS-script is running?

I try to write a PyQGIS script similar to this: Use of python console to prepare offline map from WMS (tile downloader). Basically there are two loops to pan the mapCanvas, refresh the mapCanvas and ...
2
votes
1answer
36 views

QGIS Python variable not updating after new features are inserted

I have the following script that sets the a feature id automatically after a new feature is digitized. I added the function inside the project's Macro section inside openProject() function: The ...
1
vote
1answer
13 views

Overriding method of qgis object does not work

I try to reimplement the renderDiagram() method from QgsHistogramDiagram to add some labels directly to the diagram (using the position argument). So far, I tried to set up my own class to override ...
1
vote
0answers
21 views

How to add fields to postgis layer loaded in qgis using python

I have loaded a layer from Postgis in qgis and I am adding the fields to the layer using the follo code snippet: canvas = qgis.utils.iface.mapCanvas() aLayer = canvas.currentLayer() field_name = ...
3
votes
1answer
28 views

QGIS python getting number of new features to be stored in layers

I mean, how could I get the number of features that have been created in a given layer and that are pending to be saved in the layer when "Toggle editing" or "Saving layer edits"?
2
votes
1answer
32 views

Problem using processing.runandload(…)

I'm writing a QGIS plugin using PyQGIS and I have a weird problem. When executing following line of code: processing.runandload("qgis:createpointsalonglines", r"Clipped", 1, 1, 0, r"memory:nodes") ...
1
vote
1answer
29 views

QgsMapCanvas object is not callable (Ubuntu with, Eclipse, Python & QGIS 2.0)

I'm basically borrowing the code for picking up a coordinate from a mouse click from this answer : How to programatically check for a mouse click in QGIS However in a stand alone application I do ...
2
votes
1answer
28 views

QGIS Error while executing Python function in openProject() Macro: “QgsMapLayerRegistry is not defined”

I have the following script that sets the a feature id automatically after a new feature is digitized. I want the following function to be executed automatically when project is opened (and layers ...
3
votes
2answers
123 views

Removing layers with zero features from QGIS

I have more than 100 layers loaded in map canvas. Some layers don't have any feature. I would like to delete all layer with zero feature count. Is it possible to get a script which can delete all ...
1
vote
1answer
37 views

How is it possible to programmatically export current view as georeferenced image with QGis?

I found the this to export the current view as image. The following code works and was accepted as answer. c = iface.activeComposers()[0].composition() image = c.printPageAsRaster(0) ...
1
vote
0answers
20 views

How to rollback the committed changes in the Vector Layer in qgis

I selected few features in the vector layer and updated the field. But I want to rollback the changes committed to the vector layer. How can I do that in QGIS? I have used used the following coed: ...
3
votes
0answers
55 views

How to integrate python-docx with QGIS

I have installed the newest QGIS and downloaded python-docx from this link python-docx . I haven't installed separately a different version of python. Is it possible to integrate this package of ...
3
votes
1answer
337 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
2
votes
1answer
62 views

“unexpected indent” in the script

I'm using a QGIS 2.8 in windows 10. I have 2 scripts that are working separately but when I write both in just one script, it doesn't work. The 1st script is to load one raster to QGIs with a defined ...
3
votes
2answers
50 views

Distance Matrix of two datasets

I have two datasets of the same adresses, one geocoded with Google, the other with Nominatim. Now I want to compare address1 of dataset1 with address1 of dataset2, then address2 of dataset2 with ...
3
votes
1answer
25 views

Add Values to New Column in Attributes Table using Python Console in QGIS

I've added a new column to my table called "STRNAME" using: path = "/Users/shapefiles/roads/" metro_roads = QgsMapLayerRegistry.instance().mapLayersByName('Metro_roads')[0] ...
1
vote
0answers
30 views

Setting icon for the submenu items in QGIS

I had added a new menu item as well as submenu item using the below code. I had succeeded in setting icon for all the submenus(HeatMapAnalysis,Buffer and Intersect.) But i cant able to set icon for ...
1
vote
0answers
27 views

How to automatically run some scripts for QGIS python console by defining the python macros checkbox

I'm working with QGIS 2.8 in windows 10. I've defined the python macros checkbox to QGIS start and simultaneously run a script that has the same path from my "QGIS.qgs" file. In the Project>Project ...
2
votes
2answers
1k views

How can I create a vector layer in PyQGIS from a table without geom column?

In QGIS I've got a Spatialite database containing tables without a geometry column. With the QGIS GUI it is perfectly possible to add such a table as a 'Spatialite vector layer'. But how to do this in ...
3
votes
1answer
77 views

Script that runs automatically from the QGIS Python Console when QGIS starts, using schedule tasks on Windows 10

I'm working with QGIS 2.8 and windows 10. Is it possible that after open QGIS using the schedule tasks from windows 10, I could open the python console and run a script within QGIS programmatically. ...
2
votes
1answer
26 views

Triggerring HeatMap Plugin using Python

I am trying to access heatmap plugin from Raster -> HeatMap -> HeatMap using PyQGIS.If my custom button is clicked, the heatmap plugin dialog box should opens.I know the heatmap is a c++ plugin.Is it ...
0
votes
1answer
185 views

How to connect mouseclick to map canvas in QGIS?

How to connect mouse click to map canvas in QGIS using python script? I have two lines of code to connect mouse click to map canvas: button.clicked.connect(self.onClicked) ...
1
vote
0answers
228 views

qgis python app how to add edit feature button? [closed]

I'd like to develop a QGIS Python app for plotting points and editing the attributes. I've started with the tutorials here: http://blog.qgis.org/?q=node/59 and read the cookbook ...
4
votes
0answers
28 views

Using QgsNewVectorLayerDialog

I am using QgsNewVectorLayerDialog for taking user input for creating a new shape file. When the user clicks OK i am reading the inputs selected by the user using the following code. dlg = ...
2
votes
0answers
18 views

Plug-in reloader

There's something i don't understand in the behaviour of the "plugin reloader" plugin : When an error occur in the test of a plugin "plugin reloader" reloads a new instance of my plugin (the one with ...