Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
54 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
48 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
48 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
68 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
50 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
46 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
44 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
74 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
138 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
83 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
205 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
30 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
121 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
171 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
136 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
733 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
99 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
74 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
76 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
106 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
53 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
177 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
24 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
93 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
105 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
48 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
119 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 ...
1
vote
2answers
158 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
46 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
30 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 ...
0
votes
0answers
37 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
30 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
59 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
100 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
233 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
143 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
66 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
159 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
133 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
134 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
131 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 ...
2
votes
1answer
81 views

How to load a style from POSTGIS in PyQt

The thing is that I have four styles I have created in QGIS through the GUI and saved into a postgresql database. I can see them in the table named layer_styles I have seen similar questions asking ...
1
vote
2answers
75 views

How to put a frame around a legend using QgsComposerLegend?

I can already see this being a simple answer but I'm stumped with this. I want to create a frame around a legend created by a PyQGIS script Code snippet is: legend = QgsComposerLegend(c) ...
2
votes
1answer
104 views

QGIS: Finding electric network loops

With QGIS, how can we analyse an electrical network to find loops? Using Python is not a problem, however there is not a solution in the QGIS Python API. The QgsGraphAnalyzer has dijkstra and ...
2
votes
0answers
616 views

How to rename field names in a shapefile attribute table without table manager using python

By using the table manager we can rename the field names but i want to rename of fields using python. How can i do that?
1
vote
1answer
81 views

How to read non-spatial data using PyQgis?

I'm generating maps with QGis. What I do is generate a bunch of non-spatial data on a set of cities (using VBA), and still using VBA, generate a python code that will automaticaly output general map ...
1
vote
0answers
36 views

Iteratively Change Object's Instance Attributes PyQGIS

I am trying to create new instance attributes (NOT feature attributes) for a collection of features in a vector layer in PyQGIS. I'm getting some weird results and am wondering if this is even ...
2
votes
1answer
57 views

How to place labels at the boundary of the current map extent

I have a layer of reference grid lines on top of several map layers. The grid lines should be labeled with coordinate values: vertical grid lines with x-values and horizontal lines with y-values. The ...