Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
78 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
2answers
97 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
2answers
128 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
77 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
82 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
54 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
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 ...
0
votes
0answers
58 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") ...
0
votes
0answers
49 views

GIS route creation from street names

I have a list of streets comprising 300+ routes. Each route (in text) lists 4-5 street names where the route should take place. I would like to create each route, that is, plot the street names and ...
1
vote
1answer
52 views

Create Plugin for Qgis 2.10 by using Eclipse

I finished to create my plugin and i compile it; I have : Myplugin.py, Myplugin_dialog.py, Myplugin_dialog_base.ui Is it in the Myplugin_dialog.py that i suppose to create new functions and add ...
2
votes
1answer
71 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
1answer
51 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
48 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
45 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
77 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
2answers
148 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
1answer
86 views

Suggestions of route optimization algorithms to implement in 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 wants to connect?
1
vote
0answers
49 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 ...
1
vote
0answers
231 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 ...
3
votes
0answers
44 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
140 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
190 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
143 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
788 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 ...
2
votes
1answer
114 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
82 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
81 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
129 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
56 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 ...
3
votes
0answers
188 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
25 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
103 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
122 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
49 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
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 ...
1
vote
2answers
177 views

How to prompt for layer selection from python console in QGIS?

During script development it's useful to use the QGIS python console to test the same script on different layers. Currently I've been hardcoding layer strings and just swapping out but it isn't ...
1
vote
0answers
48 views

Enable editing only one feature in a Polygon Layer using PyQGIS

I was thinking of locking neighboring polygons (parcels) by disabling editing on them, while editing would be possible on the polygon at the center. This means other polygons can also be edited in ...
0
votes
0answers
32 views

Error using gdal IDW in processing script for postgis layer

I am running QGIS 2.10.1 and I am trying to use the processing toolbox to interpolate a point layer. If I use a shape file with all the default settings it works well but if I use a point layer coming ...
1
vote
0answers
38 views

How to set QGIS mapCanvas to exact values

My QGIS 2.8.2 standalone app's mapCanvas fills a central widget with a fixed quadratic size x=y=1000 pixels. When I set the mapCanvas extent() to an area defined quadratic as well given by a ...
1
vote
0answers
32 views

add different custom SVG markers to categorized section using pyqgis

I am trying to find a way to add different custom SVG markers to the categorized symboling. I would like to have different symbols for different values but unfortunately I cannot find a way to do it ...
1
vote
0answers
63 views

Custom QGIS Processing Tool Fails to Copy Features

I'm creating a custom QGIS Processing plugin. I've created a tool that is basically supposed to copy features from an input PostGIS layer to a new PostGIS layer. My routine runs without errors and ...
2
votes
1answer
103 views

Sorting points based on Northing and Easting

I have around 1320 point/centroid features in a shapefile for my research plots. Each point/centroid has X and Y coordinate associated with them which were calculated using Field Calculator > Geometry ...
1
vote
2answers
245 views

Can't get my QGIS external map to display on Ubuntu trusty: QObject::connect: Cannot connect (null) error

I've been following along the examples from the book "Building Mapping Applications with QGIS and for the life of me I can't figure out why my shape files aren't loading and displaying in the app ...
1
vote
1answer
69 views

My QGIS plugin shows GUI but not Works. How to get Error log?

I am new to PyQgis. I made a simple calculator with PyQt4, now I am trying to run it under QGIS. I connected calculator as plugin, and tested it, its GUI works without error but it does not calculates ...
2
votes
1answer
147 views

How to launch Processing tool User Interface using PyQGIS?

I am trying to launch the UI of a processing algorithm using Python script but I cannot find a simple way for it (aside double clicking on it in the process toolbox of course). The plugin is a water ...
1
vote
1answer
70 views

What solutions to use QGIS as insert tool for a Postgres relationnal database?

I have a Postgres/PostGIS relational database and I would like to use QGIS as an interface for inserting data. The thing is that my database is quite complex and I need my tool to handle the following ...
2
votes
1answer
180 views

How to find if map layer registry is empty?

In my script I want to open layer named my_layer if it is in the map layer registry. I use following code for it: inputLayer = QgsMapLayerRegistry.instance().mapLayersByName("my_layer")[0] If not ...
8
votes
0answers
140 views

How to access a deleted features attributes (before committing)

I have a signal setup for a feature deletion event on a layer: self.layer.featureDeleted.connect(self.feature_deleted) When I try and grab an attribute from the deleted feature on the slot, a ...
1
vote
2answers
136 views

Polygons in one layer have different attributes

Is it possible in PyQGIS to have in one layer more polygons and some would have one set of attributes and another different? E.g. Polygon_1(name, size, average_age), Polygon_2(name, size, ...
3
votes
2answers
147 views

How can I create a QGIS plugin that needs an external Python library?

I’m trying to enhance QGIS's Profiletool plugin by adding DXF export functionnality. For this, I need to to import dxfwrite library. As it's installed on my computer, i added the following lines to ...