Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
2answers
24 views

How to show variable values in message bar in QGIS?

I know that I can write custom text to message bar with the QgsMessageBar.pushMessage() method. But if I understand the documentation right, there's no room for variables added to a string where they ...
1
vote
1answer
13 views

How to register a broadcast on QGIS to start my plugin on start after loading plugins

I want to perform a default task when user opens QGIS but here I am building it as a python plugin so I want a signal or broadcast to call my plugin. I didn't build QGIS from source my plugin should ...
1
vote
0answers
24 views

Multiprocessing in python qgis?

When i try to do mutliprocessing in python Qgis it doesn't work from multiprocessing import Process,Lock import multiprocessing def name1(l,i): print i if __name__=='__main__': lock=Lock() ...
1
vote
0answers
19 views

Remove inner rings from QgsGeometry polygon in QGIS Python

I am a QGIS python user. I want to iterate over rings of polygon to remove holes in polygon, so: I need to iterate over rings in QgsGeometry polygon I need to detect main ring of polygon I need to ...
1
vote
1answer
46 views

Python script to copy first row of certain attributes and paste in the newly digitised rows the copied features

Starting from this question, I need a script to be insterted in the processing graphical modeler that can copy some attributes from the first digitised row in all the newly digitised lines of a ...
3
votes
1answer
55 views

How to toggle Map Tips with PyQGIS?

I want to display "map tips" in QGIS with python for my custom map canvas QgsMapCanvas(). How can I do this? I can switch manually with View/Map Tips but it won't work with my custom canvas in my ...
2
votes
2answers
45 views

How to find the irregular polygons in qgis using python

I have a vector shape file and i want to find the irregular polygons. What are the parameters to be considered to check the iregularity of the polygon features? Calculating the perimeter and extent ...
3
votes
5answers
65 views

Is there any simple integration for counting points in polygon using python qgis?

Is there any simple integration for calculating count of points in polygon using QGIS-Python integration? In other words, are there any pre-defined functions for points in polygon of QGIS using ...
2
votes
2answers
30 views

Store in a python list the attribute table of a vector in QGIS

I'm stuck with a very simple issue.. I've loaded in QGIS (through the py console) a csv layer (no geometry) made of 4 fields and 3 rows: #load the csv layer = QgsVectorLayer("path/to/the/csv", ...
0
votes
1answer
31 views

Can we count the points in polygon using pyqgis code? [duplicate]

Does anyone know how to calculate the point in polygon from the given points and the buffer output using python qgis. I have every thing loading the data and retrieving the output. But now I want to ...
4
votes
2answers
80 views

Loading a WFS layer using pyqgis

I'm trying to load a WFS layer in PyQGIS. My WFS uri is for county boundaries here in England. It's open data and pretty light, if you were wanting to recreate the issue. Here's my code: uri = ...
1
vote
0answers
10 views

How to modify the “Network Analysis Library” in QGIS?

I want to modify the network analysis library because th graph builder does something I don't want. When there is an intersection between to lines, it creates a node in it. I want to avoid this ...
1
vote
0answers
42 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 ...
2
votes
0answers
60 views

Can we create buffer analysis using python in qgis?

Can we create a buffer of distance 0.004 using python in qgis. I tried this link, but it isn't working for python in qgis 2.10.1-Pisa. The above is the diagram of buffer I am asking. It's located ...
5
votes
1answer
87 views

How to exit QGIS after running a python script?

I would like to run a python script via qgis --code myscript.py and then immediately exit. I'm using iface.actionExit().trigger(), which kills QGIS when I run it from the python console, but not when ...
0
votes
1answer
30 views

pyQgis - set Variables on startup

via startup.py it is possible to execute python code when qgis starts. Now I wonder, whether it is possible to set variable values, eg. a string variable which holds a path or a dictionary of values, ...
2
votes
1answer
39 views

How can I access to elements in dir(some_class) of PyQGIS without a dictionary in my code?

I'm developing a QGIS plugin to search class methods in the different classes of PyQGIS. I used three widgets: 2 objects of type QLineEdit (for classes and class methods) and one QTextBrowser (for ...
1
vote
1answer
21 views

Unable to update some of the attributes using PyQGIS

I'm trying to create new attribute and populate it, but for unknown reason some of the features does not update while others are updated normally. # scores - list of values which length is equal to ...
1
vote
1answer
37 views

How can I get the first selection of a layer in a QgsMapLayerComboBox?

I'm developing a very simple QGIS plugin to calculate raster average by using GDAL. It uses a QgsMapLayerComboBox and a filter to select only raster layers. However, it needs to select twice a layer ...
0
votes
0answers
16 views

Attribute table that allows editing

I am converting some data for QGis. I created plugin that can do it. Some data I save in csv file. There is no problem load that csv file into QGis and work with it. But I need to edit values in that ...
0
votes
1answer
11 views

How to use SpatialOperator in filter expression in QGIS

In a python script I want to specify a request filter expression using a spatial operator. I am following the general syntax "field name" operator condition. For example: ...
0
votes
1answer
28 views

How to save layer as dbf using pyQGIS?

Is it possible to save layer as dbf? Or even better convert .csv to .dbf? I have some .csv files, no geometry just attributes and I need it as .dbf as I want to edit them (I found that Qgis doesn't ...
1
vote
0answers
23 views

How to load and execute python scripts from a local path after python console is triggered in QGIS?

I had created a file named "startup.py" in users python home directory (... .qgis2/python) and i had triggered the python console in startup.py file by import qgis ...
1
vote
0answers
20 views

PyQIS add values to QGIS qml style file

I wonder if it is possible to add new styles to a QGIS style qml file with categorized values programmatically. I have for example a large qml style file and want to add a new definition for ...
0
votes
0answers
28 views

Error's while retrieving data from postgres to Qgis using python?

This is my code of python in qgis from qgis documentation docs uri = QgsDataSourceURI() uri.setConnection("localhost","5432","gis_data","postgres","vajja") ...
1
vote
1answer
23 views

Create Plugin for Qgis 2.10 by using Eclipse

I finished to create my pluging and i compile it; I have : Myplugin.py, Myplugin_dialog.py, Myplugin_dialog_base.ui 1- Is it in the Myplugin_dialog.py that i suppose to create new functions and add ...
2
votes
1answer
33 views

Difference between qgis.utils and qgis.core?

Please, can you tell me what is the difference between qgis.utils and qgis.core ? I'd like to understand step by step the QGIS API Document.
2
votes
2answers
60 views

PyQGIS Use of predefined color ramps

I´m trying to apply one of predefined color ramps to a categorized field in a vector layer. To do this, I'm using the code below suggested by Irssvt in another post. However, I cant´t see the result ...
1
vote
1answer
31 views

CategoryList attribute for predefined color ramp in pyQgs

I am trying to style my vector layer in QGIS using the following python code: layer = iface.activeLayer() myStyle = QgsStyleV2().defaultStyle() defaultColorRampNames = myStyle.colorRampNames() ramp = ...
1
vote
0answers
15 views

Generating polygons based on georefernced Raster image

I have an aerial imagery of a crop field, each of these polygon-looking-group-of-crops-together is called plot. I need to make a polygon shapefile that overlays on top of these plots in the image. I ...
2
votes
1answer
36 views

I tried to run QGIS using python but I couldn't get any output on screen?

uri ="C:/Users/rajagopalv/Desktop/poi_sunnyvale.csvdelimiter=%s&xField=%s&yField=%s" % ("|", "x", "y") vlayer = QgsVectorLayer(uri, "address_sunny", "delimitedtext") ...
1
vote
0answers
22 views

How to write a loop selection by location and export in QGIS?

I would like to be able to make selections in sequence between buffers and surrounding areas. This would lead to areas (polygons) being selected repeatedly by 2 or more buffers and I want to be able ...
1
vote
0answers
37 views

CSV file locked for editing after join

I have created a table join between a vector shape-file and a csv file using pyQgs. Now i want to edit the csv file (not from inside QGIS) . But when i double click on the csv file , it says that ...
1
vote
1answer
166 views

How to enable the snapping options for vector layer using the python programming?

I want to enable the snapping options for the the existing layers using python programming. How can I do this?
2
votes
1answer
173 views

How can i add a north arrow in QgsComposition?

I'm trying to add an svg image of north arrow in QgsComposition using this code: mapRenderer = iface.mapCanvas().mapRenderer() theComposition = QgsComposition(mapRenderer) ...
4
votes
2answers
258 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
1
vote
0answers
27 views

Suggestions of route optimization algortihms to implement on QGIS

I need to compute routes on a QGIS project with time and distance associated. Is there any route optimization algorithm to compute routes given the points that one want to connect?
1
vote
0answers
28 views

QGIS 2.10.1 : Function editor tab indents generating errors …?

i'm trying the function editor in QGIS 2.10.1 (windows 32 bits). I always get "indents" error as the function editor inserts TAB indents instead of spaces ... How do i solve this issue ? Thanks ...
0
votes
0answers
26 views

PYQGIS Refresh map composer

I have the same problem as this How to set up QGIS print composer options from the python console? I have a composer template called "Template", I can open it with the python console but not edit the ...
2
votes
1answer
214 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 ...
1
vote
0answers
19 views

QPyNullVariant when working with csv

id = 5 expr = QgsExpression("ID ="+str(id)) selected = csv_layer.getFeatures(QgsFeaturesRequest(expr)) features_list = [feature.attributes() for feature in selected] print ...
3
votes
1answer
699 views

How to delete selected features in Qgis using Python

I have a shape file with only one field DN. I would like to delete all features which does not have specific value of the field. Let say the DN can be 1,2 or 3. So far I was able to find out how to ...
1
vote
0answers
14 views

Create and save composer with Python

With Qgis 2.8 I need to create some composers based ona template, and save them using Python. I've found how to load a template in a composition, but I do not find how to save this composition in the ...
2
votes
1answer
222 views

Accessing CRS info with pyqgis in a standalone application

I'm currently having trouble accessing and defining CRS information in a standalone application. I've read the API documentation and have tried it in the python console in QGIS 2.2.0. The python ...
2
votes
1answer
29 views

How to use spatial filter in PyQGIS?

I have a buffer and need to filter a multipoint layer (QGSVectorLayer) so that I would get only features intersecting the buffer. What I've found: a) setFilterRect() This doesn't accept polygon ...
2
votes
1answer
57 views

pyQGIS changing Paletted Raster Layers to Grayscale

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

Using PyQGIS, ArcPy, NumPy, SciPy Together in Windows Command Prompt

I ran across this slight issue when I was looking to access python installations from ArcGIS, QGIS, Anaconda (cited because SciPy & NumPy come with it), and version 2.7 vs 3. Sometimes, I find it ...
1
vote
1answer
42 views

Programmatically import new composer from template to project using pyQgis

I am trying to find information about how to programmatically import new composer from template, but it is impossible. There is a lot of information how to print the composer to image, but not save ...
2
votes
1answer
40 views

QGIS 2.8+: How can layer.selectedFeatures() return an empty list while layer.selectedFeatureCount() returns the correct number of selected features?

I noticed some changes since qgis 2.8 but can't find any information about it. Let's say I have a very simple point layer loaded in QGIS, from a spatialite table. From this layer I select some points ...
1
vote
1answer
167 views

Using two different Python versions for QGIS scripting?

I´m intending to learn scripting with python in QGIS, but I have a couple of questions. I'm using Python 3.4 for learning which is installed in my laptop, but QGIS is using Python2.7 How could I ...