Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
1answer
77 views

Works in Console but not in Script Editor

On QGIS, I am using a simple script to zoom the selected features. I write them in the Text Editor, but it didn't work until I used the console... and it does work. What kind of problem is this? Is ...
1
vote
0answers
10 views

provider.addAttribute $area [duplicate]

I'm trying to add the attribute $area. I made a intersection and Tot_aera isn't the good one, so I want to add a new. I made that : from PyQt4.QtCore import * try: if ind==-1: if caps ...
1
vote
0answers
35 views

PyQGIS: vector layer does not get displayed after rendering

My project goal is to write a standalone app for Unbuntu and QGIS 2.14. It should get a layer of simple points and their name from a Postgres database and show them in a layer. In addition there ...
1
vote
1answer
70 views

Load multiple files from folder for further processing

I'm working on a processing model and I'm looking for a possibility to load multiple shape-files from an Input-folder for further processing (first clip them all to a certain extend, then assign them ...
3
votes
1answer
102 views

Using processing algorithm in QGIS plugin

I'm building a plugin in QGIS, one of its part is processing algorithm: intersection. I want to save the result as memory layer, and then work on it. Following code was working fine, nothing changed ...
4
votes
1answer
100 views

Implementing NNJoin in Python

I am curious to know on how to implement NNJoin into the python code. I have created a point shapefile using shapely. I have another shapefile which is a centerline and is used as a reference line. ...
3
votes
1answer
37 views

How to read help() from QGIS classes

I'm trying to copy a shapefile and give it a new name in QGIS python console, I am trying to use the QgsVectorFileWriter class' writeAsVectorFormat method writeAsVectorFormat(...) ...
3
votes
0answers
41 views

Gdal and module import error when creating an .exe application with pyinstaller

I’ve been struggling since three days in a row to create a windows executable application from my python application. I have managed to get results but I’m not at all satisfied with the workarounds I ...
3
votes
1answer
37 views

How to set the color of a feature depending on field attributes with PyQGIS?

from PyQt4.QtCore import * from PyQt4.QtGui import * def Symbology(): canvas = qgis.utils.iface.mapCanvas() layer = qgis.utils.iface.activeLayer() for feat in layer.getFeatures(): ...
4
votes
2answers
135 views

How to find disconnected islands in a road network layer, using QGIS

I have a road network layer that can't route from one side of the layer to the other. Topologically, there is no connectivity between the start and end nodes, probably due to missing links. This ...
1
vote
2answers
69 views

QGIS equivalent to arcpy.SearchCursor?

What is the equivalent in QGIS (or other FOSS) to this: rows = arcpy.SearchCursor(table, fields="ORIG_FID; field1; field2; field3; field4", ...
1
vote
1answer
21 views

Why would having a reference string “boh@10” cause a crash?

When using the raster calculator in a pyqgis script, I have several layers to process. When it gets to "boh@10", the processCalculation() call crashes. I don't see anything in the code that requires ...
3
votes
1answer
59 views

How to get the feature id of features added to dataProviders?

My question is somehow related to the problem of finding the id of the last added feature: I am looking for a way to supply the feature id and another attribute of each added feature through a signal. ...
1
vote
1answer
64 views

How to create a new database in spatialite and insert the data using python in Qgis

I want to create a new database in spatialite and want to connect to the database and execute the sql queries. conn = db.connect('myDB.sqlite') # creating a Cursor cur = conn.cursor() sql = 'select * ...
0
votes
0answers
10 views

loading SpatiaLite tables with WHERE clause with pyqgis

the question is very simple. I have some layer in a SpatiaLite database that I want to filter and load in QGIS through pyqgis. From the pyqgis cookbook I read that it is possible to add a WHERE ...
2
votes
2answers
84 views

How to convert the CSV to point shape file using python

import csv,sys import osgeo.ogr, osgeo.osr #we will need some packages from osgeo import ogr from osgeo import * import osgeo.osr as osr def test(): boolValue = True canvas = ...
3
votes
2answers
44 views

Cannot load vectorlayer PyQgis

I am having a hard time loading a vectorlayer from the console. Not from the Pythonconsole within QGIS, but from the console on my computer. I later want to write a standalone script! That is what I ...
1
vote
0answers
35 views

Form opening after stopEditing pyqgs Qgis

I made a form that binds some fields on a shp in Qgis (works fine), and after stop editing event the form appears again.. Do you have any ideas? Made so far: ## action self.editingObject = ...
3
votes
1answer
61 views

QGIS Add feature python script

New to python, and been looking at this for a while, trying to write a scrip to automate a process we need to carry out in QGIS a few thousand times. As part of this I need to create a feature into an ...
2
votes
1answer
36 views

QGIS - How to update Python Init Function

In layer properties I can set a "Python Init Function" and it works perfectly. But I can't find a way to update it when developing (without closing QGIS).
7
votes
1answer
83 views

Compute zonal statistics for portion of polygons

I am working with a shape file containing the district polygons of the political map of India and a raster file containing the elevation data of the same country. My goal is to compute the average and ...
2
votes
1answer
122 views

Adding QGIS-specific Python interpreter to Eclipse?

I was following the steps from QGIS Python Programming CookBook to add qgis interpreter to eclipse, however I went into the following error in step 8: "See error log for details. No output was in the ...
1
vote
2answers
56 views

geometry less memory layer in QGIS

I'm writing a QGIS plugin and I need to create a table with some attributes that, in a second moment, I'll load in a SpatiaLite database. The table is created as a memory layer, but as I said, it is ...
2
votes
3answers
77 views

Can not Run function when item selected in comboBox. Pyqgis. QGIS

I'm writing a plugin, I want to change the content of a comboBox (fields) depending of the content of another comboBox (layers). My plugin is a dockwidget. I can populate the fields comboBox just ...
2
votes
1answer
60 views

pyQGIS segfault

I am trying to get started with pyQGIS but failing pretty hard. Trying to follow http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html A lot of it seems incomplete for Windows ...
5
votes
2answers
93 views

Why can't I multiply values from column named 'length' using field calculator via PyQGIS?

I want part of my plugin to multiple value of length and add it to table.Basing on this question: How to use QGIS field calculator in python? , I made script that works fine for some filed: I can ...
1
vote
0answers
48 views

Using pyqgis to create images from the QGIS print composer each showing a different layer

I have many vector layers which I want to display and print, one at a time. The following script works well for producing an image from the map canvas, but I want to produce an image from a print ...
4
votes
1answer
52 views

Load WMS with PyQGIS

I have installed QGIS server on Ubuntu 14.04 which serves WMS. Connection uses https and basic auth. URL is https://my.awesome.url:8090/cgi-bin/project1/qgis_mapserv.fcgi I can connect with QGIS and ...
6
votes
0answers
93 views

Can a memory layer be used as an input and/or output with runalg?

Can a memory layer be used as an input and/or output with runalg? With runandload I get this to work: processing.runandload("qgis:mergevectorlayers","memory:bufferOne", "memory:bufferTwo", ...
6
votes
1answer
49 views

QGIS crashes when doing a rollback after modifying values of an user-added feature with pyQGIS

I'm developing an addon for QGIS that needs to assign a UUID to any feature as soon as it is added to the layer. I'm using the featureAdded signal to write the UUID in the corresponding field of the ...
2
votes
1answer
27 views

Error on pyqgis dot density maps: no attribute bounding box

I have been using this tutorial to try to make a dot density map using python within QGIS, and my code shamelessly draws from the linked tutorial: import random src = "~/maps/SAMS_areas.shp" tractLyr ...
3
votes
2answers
54 views

QGIS pyqgis: Trouble loading non-spatial data via .csv using python for standalone script

I cannot for the life of me figure this out. I am trying to load a .shp file, and a non-spatial data table .csv file. Then join the table to the shape file. Both files have a primary key. Here is ...
3
votes
1answer
38 views

While populating table of memory layer one record is missing

I have script that calculates length of lines and adds values to attribute table. It works for vector layer, but for memory layer it skip always one value, as you can see on the pic. I calculated ...
2
votes
0answers
32 views

Extracting one band from multiple stacking raster layers using PyQGIS? [closed]

I've got 1000 (one thousand) RapidEye raster images. The stacking layers has bands 1, 2, 3 and 4. I need to extract the bands 1, 2 and 3, then save the new file discarding the band 4. I've tried to ...
2
votes
1answer
18 views

Trying to get PRECISE vector coordinates using geom.asPolgon

I've got a bit of a problem. A script I've written is trying to get the coordinates of every vector in a layer, which is MAINLY working: output_file = open('c:/myfile.txt', 'w') layer = ...
2
votes
1answer
51 views

programmatically populating the QGIS Legend

So I have a function in a utility class that creates my Legend for the composer. It looks something like this: def addLegend(self, c, r, L, tree_root): L.model().setLayerSetAndGroups(tree_root) ...
4
votes
0answers
25 views

Qgis Python - Legends in Horizontal

I have successfully added legends in Map using Qgis QgsComposerLegend () python programming .(using Qgis python console) but legends are added vertically.I wanted to place legend horizontally. If you ...
3
votes
1answer
59 views

Adding attributes to the table PyQgis

I want to save number of vertices of every object from my line vector layer in attribute table. The code I have was able to: Save in table correct number of vertices for layer with only Polylines. ...
0
votes
0answers
20 views

QgsMapCanvas with semi-transparent layer causes graphic artefacts

I'm trying to set a background image (in my case a google map shot) for QgsMapCanvas with semi-transparent layers upon it. Therefore, I set alpha of background color for canvas to zero and create a ...
2
votes
1answer
41 views

How to set CRS for a DXF file and prevent any warning on QGIS using pyQGIS?

I am trying to import dxf file with no warnings or popup from Spatial Reference Selector. However, even after modifying QGIS Spatial Reference Selector setting, I still get a qgisMessagebar warning. ...
1
vote
0answers
16 views

Pyintaller cannot find pyqt4 plugin directories for a PyQGis program

I have a PyQt application that I am trying to compile into one exe using PyInstaller 3.1. It does compile into an exe, however, the GUI doesn't show up upon launch (clicking the exe). One of the ...
4
votes
0answers
27 views

Parallel feature request connection limit

I have a large pool of feature requests that need to be performed on a PostgreSQL layer. Please assume that these requests cannot be joined into larger requests. If I spawn several threads to perform ...
1
vote
0answers
42 views

Filling in An Attribute Column with Values from a List in a standalone python script

I have created an empty attribute column A via the following lines: Layer = QgsVectorLayer("/home/usr/Desktop/File.shp", "File", "ogr") QgsMapLayerRegistry.instance().addMapLayer(Layer) lProvider = ...
3
votes
1answer
58 views

Subsetting a shapefile and saving it using PyQgis

I am very new to PyQgis. I have a shapefile containing a lot of information for each place, it looks like this id stat_1 stat_2 ... stat_n i1 0 0 2 i2 1 1 ...
1
vote
0answers
32 views

Getting QgsGemetry.fromWkt to show up?

I am following a tutorial from "QGIS Python Programming Cookbook", and I am having some trouble, even with a near exact replication of the code, and I could use a second/third pair of eyes as to why I ...
4
votes
1answer
67 views

QGIS: Script is being executed successfully in Python console (within QGIS) but not in a standalone python script

I have the following code which I have no problem executing within QGIS (2.8.6) via the python console. What the script does is it adds the two raster layers in my directory via the Raster Calculator: ...
1
vote
0answers
35 views

Create new layer and populate attribute table from QtWidget PyQGIS

in my QGIS plugin, one of the dialog has a QtWidget table where the user can add items to the columns. Each column of the table is a single list and the final result is a dictionary where the keys ...
6
votes
3answers
108 views

Counting number of vertices of object on vector layer PyQGIS

First of all, I want to say that I know that similar issue was raised before, but it didn't provide satisfying solution. I need to get the number of vertices of every object on vector line layer. ...
4
votes
0answers
44 views

How do I implement PyQGIS multithreading to update a progress bar

I am developing a PyQGIS plugin using python. I facing a problem during the implementation of threading in my plugin. I have written a python script which contains a class wrapping all geo-processing ...
3
votes
1answer
59 views

Build a table with columns of raster values from multiple raster datasets, using Python, GDAL, or PyQGIS?

I have a series of raster datasets, clipped to the same extent, with matching cell resolutions, each of which represent land surface temperatures (LST) captured by the MODIS sensor. Each raster ...