Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
2answers
49 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
14 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
25 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
47 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 ...
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", ...
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
66 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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
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 ...
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 ...
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
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
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: ...
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 ...
0
votes
0answers
30 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
24 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.
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 ...
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
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 ...
2
votes
1answer
37 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
38 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
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 ...
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 ...
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 ...
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
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 ...
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 = ...
3
votes
1answer
57 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 ...
3
votes
2answers
205 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 ...
0
votes
0answers
30 views

How to get the polygon vs. Polygon Intersection Coordinates using python

I want to find the intersection coordinates between two polygons. aLayer = canvas.currentLayer() selection = aLayer.selectedFeatures() for geom1,geom2 in itertools.permutations(selection,r=2): ...
1
vote
0answers
14 views

PyQGIS Set Extent for loaded layers - Refresh problem

I've written a plugin which loads a number of map layers (based on constraints) and I would then like to set the canvas extent to a selection of them. Code very similar to that below works perfectly, ...
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
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 ...
1
vote
0answers
27 views

Help rendering shapefiles (.shp) to TIF with labels

I'm running into some problems here. I've basically copied the script below with minor tweaks from a few other posts here on stackexchange. When I run my code and all I get for output is a TIF that's ...
1
vote
0answers
53 views

QGIS 2.8 Python Plugin Unittest Segmentation Fault 11

UPDATE: This issue may be isolated to my MacBook. The seg fault did not occur in testing on Windows. I have put together a sample unit test for a QGIS python plugin. It is causing a Segmentation ...
1
vote
0answers
15 views

QgsPalLayerSettings is not defined

So I'm writing some script for QGIS 1.8 and I'm unable to resolve this error. from qgis.core import * pallyr = QgsPalLayerSettings() The second line gives me error that QgsPalLayerSettings is not ...
1
vote
0answers
41 views

Can QGIS handle EMPTY geometries?

I am writing a plugin and have a postgis table which has EMPTY geometries in the geom column. MULTILINESTRING EMPTY I am having crashes which just close QGIS. I have narrowed it down to the EMPTY ...
1
vote
1answer
32 views

Get distance from point to nearest edge of polygon with PyQGIS

I have 2 .shp layers in my workspace, polyLayer and pointLayer Using PyQGIS I'd like to be able to get the distance from the point to the nearest boundary of the polygon. I've done this sort of ...
0
votes
1answer
19 views

Add event listener on QGraphicsEllipseItem

I'm creating a QGis Plugin in python which has a QGraphicsView in which I draw and ellipse on which I want to detect if the user clicks. I know the ellipse inherits QGraphicsItem which has a ...
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 ...