Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
0answers
51 views

PostGIS and QGIS connection using queries?

I have a shapefile and a table which I import both of them to PostGIS. With pgAdminII I am able to manipulate the table, join to shapefile and calculate new fields. When I try to do that with python ...
4
votes
3answers
507 views

Change QGIS background colour using python

I would like to change the background colour of a QGIS project using python. I can change the colour using the GUI via the Project Properties dialog: However, I cannot find the equivalent setting ...
5
votes
1answer
273 views

How to replace a shapefile name in a directory using Python QGIS?

How to replace name or delete .shp file from directory using Python QGIS ? import os import processing input = "//input.shp" output = "//output_100.shp" interval = 100 processing.runalg("qgis:...
3
votes
1answer
77 views

How to fix Quickfinder OperationalError: table quickfinder_info already exists?

This is what I am getting when I try to search in project layers and create a .qfts file to use quickfinder on a local shapefile. An error has occured while executing Python code: Traceback (...
7
votes
2answers
194 views

Why do I get different results from PyQGIS feature.geometry().type()?

On the python console in QGIS what is the difference between the following two code snippets (activeLayer is a polygon layer): # 1) iface.activeLayer().selectedFeatures()[0].geometry().type() >>...
1
vote
1answer
72 views

How to select attributes by unicode field value?

I have an attribute table in QGIS 2.10 with a string field (myfield) and when I want to make a selection based on the unique values of this field I get no selection at all. >idxmyfield = mylayer....
1
vote
0answers
22 views

Creating menu item and adding more than 1 plugin in QGIS?

Because if I execute these lines for each plugin, I created a menu item for each plugin. I created many plugins and wish to place them in a new menu item (not traditionals)
4
votes
3answers
191 views

Quickly make server side spatial filters for WFS layers based on other layer's selected geometries in QGIS

In QGIS 2.12.1, I have a WFS layer which is huge so I don't want my users to load it entirely but only parts of it based on intersections with geometries. Today, I'm using the query builder and ...
1
vote
0answers
70 views

Can you build a login window in QGIS?

Can you build a login window before loading QGIS interface? I use QGIS 2.8 I just built message windows when loading QGIS interface, but no more.
4
votes
1answer
110 views

How to get the list of QgsPoint from a polygon Layer in pyqgis

I have a little question about how to manage the points in a layer. from qgis.core import * def run_script(iface): layer = QgsVectorLayer(layerType.Polygon+'?'+crs.psg_4326, ...
32
votes
4answers
966 views

Generating equal sized polygons along line with PyQGIS?

I would like to create polygons along a line to use them for AtlasCreator in a next step. ArcMap has a tool called Strip Map Index Features. With this tool I can choose the height and width of my ...
3
votes
1answer
91 views

PyQGIS - Densify geometries given an interval

I have question, is it possible to make python command for QGIS function "Densify geometries given an interval": input layer: Polygon.shp output layer: Densify_interval.shp interval: 50 meters for....
2
votes
0answers
96 views

heat map plugin from QGIS python console

I am trying to use the heat map plugin from the processing console. On the QGIS documentation it says the plugin uses Kernel Density Estimation. I have used the saga Kernel Density Estimation but do ...
3
votes
1answer
207 views

Using standalone pyQGIS application QgsApplication.initQgis() fails?

I'm trying to execute the following code on a windows 7 system: import qgis.core as qc qgis_path = "C:\Program Files\QGIS Lyon\apps\qgis" qc.QgsApplication.setPrefixPath(qgis_path, True) qc....
2
votes
1answer
60 views

Clean way to identify color scheme in Python QGIS

When I do in the Python QGIS console QgsColorSchemeRegistry.instance().schemes(), it returns the following [<qgis._core.QgsColorScheme object at 0x7f6cc5d8ccc8>, <qgis._core.QgsColorScheme ...
1
vote
2answers
137 views

Select feature one by one not working in pyQGIS?

I have used following code for selecting the features one by one. but when i run the script it is just selecting last feature and zoom it. I want to select each feature and zoom it. def ...
6
votes
1answer
425 views

Getting QGIS python modules to work from PyScripter in Windows 10?

Been trying lots of "solutions" from net research but nothing seems to work. I have the current versions of QGIS from OSGEO and PyScripter 2.5 Based on one of the solutions I tried... import sys ...
4
votes
1answer
97 views

Select feature one by one and save it as image

I have used following code for selecting the features and save it as image. layer = self.iface.activeLayer(); layer.setSelectedFeatures([]) count =layer.featureCount() lstChalta = [] lstFeatures = ...
2
votes
2answers
75 views

PyGIS remove QgisVertexMarker from scene

I am writing a plugin that includes interaction with the map. Therefore I use a QgsMapTool. It is possible for a user to mark a point on the map. When the user clicks a red X is drawn on the mapCanvas ...
1
vote
1answer
71 views

How to change and display the plugins icon in the menu in QGIS

I want to add multiple icons in the same file to display the plugins icons in the menu. def initGui(self): action = self.add_action( ':/plugins/Example/icons\icon1.png', ...
3
votes
1answer
206 views

PyQGIS - polygon to lines with geometry length and select features with condition

How can I make a script to convert polygon layer to explode lines ? After that I need to get geometry length for conditioned features. I have a part of code ? import processing processing.runalg("...
2
votes
1answer
122 views

Creating set of maps (PDF) using QGIS and Python with WMS Data

For a scientific project I am trying to create a set of PDFs in QGIS with a fix layout (in the print composer) but per PDF a) different map item attributes (extents) and b) a QR-code to identify this ...
3
votes
1answer
122 views

Split feature by line in PyQGIS

My objects are a polygon and a line. I want to split my polygon according the line. I have used reshapeGeometry and splitGeometry with no success. ReshapeGeometry returns 0. Polygon-foo foo = ...
3
votes
1answer
57 views

Unable to print anything or write anything to file in python after importing processing

I've been trying to get standalone QGIS python scripting to work, but for some reason after I import processing, I cannot print anything to the console, nor can I write anything to file. My end goal ...
1
vote
1answer
53 views

Random sample from selection

I have a selection in vector point. I would like to do random sample from it. I am using qgis to do it. Here is my selection code: selection=layers_canvas[0].getFeatures(QgsFeatureRequest()....
2
votes
1answer
185 views

Load a GeoJSON layer with QGIS's Python module

I have been able to load a GeoJSON file into QGIS by simply clicking "Add Vector Layer", and selecting my file to load. Now I'm using the qgis.core Python package, and I'm trying to load the GeoJSON ...
2
votes
0answers
28 views

QGIS plugin window qt creator formatting ineffictive

I am developing a QGIS plugin. I have assigned the QGIS main window as the parent window of custom plugin using: QtGui.QDialog.__init__(self,iface.mainWindow()) But after doing so the problem ...
1
vote
0answers
30 views

QgsCategorizedSymbolRenderer default ramp colors

I have a plugin and I want to symbology a vector file with some default ramp colors but I see that in graduated symbology is not so easy as in graduated symbology. Is it possible to assign a default ...
2
votes
2answers
608 views

Return list of selected items of QListWidget PyQt QGIS

I'm a little bit confused (I'm a newbie) on how to get a list of just the selected Items of a QListWidget (in a QGIS plugin). I set up the manageGui function in this way: def manageGui(self): ...
2
votes
1answer
87 views

Displaying RGB raster on QGIS with no enhancement with Python Console?

I'm working with a RGB raster on QGIS 2.6.1, on a Windows 7 machine. I need to set the Contrast Enhancement option to No Enhancement with the Python Console (not through the Layer Properties window)....
1
vote
1answer
103 views

Pyqgis : how to close composer window?

I would like to load new composers from template files (*.pqt) when I open my plugin. I managed to do it using this helpfull post Programmatically import new composer from template to project using ...
3
votes
0answers
102 views

spatial index intersection with qgsrectangle only computes polygones

I have the problem, that i only get polygon features inside my defined rectangle. If i switch off my polygon layer(s) i get my lines. TOC: Line-Layer on, Polygon-Layer on: i only get Polygons which ...
5
votes
1answer
252 views

Do I have to publish own QGIS plugins?

If I develop QGIS plugins for my company do I have to make them available to others? I use QT-Designer and think that it also depends on the question how you develop your plugins, right? For example: ...
3
votes
1answer
174 views

Has the “Warp (Reproject)” tool changed in QGIS 2.12?

I am writing a QGis plugin, for QGis 2.10, which imports processing 2.10.3, that needs: testproc = processing.runalg('gdalogr:warpreproject', thisName, # input ...
4
votes
1answer
157 views

Drawing polygon in qgs map canvas

I want to make a custom application which includes an option just like the "Select Features by Polygon" feature in the qgis. I am able to draw the polygon using following code: self.rb = ...
1
vote
1answer
96 views

PyQT: QFileDialog keeps on opening window after clicking on cancel or ok

I use to write QGis plugins, which is based on PyQT. I use to create QButtons and connect their click to a function that itself calls a QFileDialog. For example: def doOpenFile(self): fname =...
2
votes
1answer
139 views

How to change default symbol in Categorized symbol renderer (python console) or use different icons as vector layer symbols?

I have a point shapefile in QGIS 2.10 and I want to display one of its fields attributes based on its unique values (I always know that it has 4 unique values and their values so I do not care for the ...
6
votes
2answers
316 views

Skeletonize vectors in QGIS/Python

I am trying to find a tool to create a skeleton of a large vector dataset using QGIS and its bundle. It should be directly programmatically callable through Python or commandline (QGIS, GRASS, OGR etc....
0
votes
0answers
46 views

Memory issue? qgis python processing does not complete

I have a simple process to make some edits to all the contour files in a directory. It runs fine on the test of 100 odd files but in a directory with about 500 it stops after about 120 files. Is ...
1
vote
1answer
56 views

store function attribute of class in QGIS plugin

I'm pretty new to python and pyqgis so the question will be pretty trivial.. I'm writing a plugin and in one script I have a class and some internal functions.. .... class CreateModelDialog(QDialog,...
0
votes
1answer
67 views

Spatialite function to generate a blob from a geometry

Using QGIS Python API, I want to avoid updating geometry with an UPDATE sql command. Why? I'm using a QSqlRelationalTableModel (see model-view programming if curious) and there are built-in editing ...
2
votes
1answer
34 views

Open CSV with native QGIS Widget

I am writing a plugin that offers to open a CSV. I know the local path to the CSV but I don't know if it contains spatial data nor which name the X and Y could have. The best way I can think of, is ...
2
votes
1answer
109 views

QGsComposerLabel set text

I am building a composition with map, legend... I want to add a paragraph (text) to the composition but the text only recognize one word. What I am doing wrong? Code: text = QgsComposerLabel(...
1
vote
1answer
72 views

setHeaderData not working in a QgsAttributeTableModel?

I want to display the content from a layer in a new view I have so far a code like below (you should have 2 columns at least, then, just try in the QGIS Python console replacing mylayer_id) from ...
2
votes
3answers
155 views

Running PyQGIS script in Windows

I'm not able to run the following PyQGIS script in Windows (it worked perfectly in OS X): import sys import os from qgis.core import * import qgis.utils from qgis.analysis import * app = ...
1
vote
1answer
58 views

How can a gui be visible till all the work is done? (QGIS plugin, python)

I have made a gui in QTDesigner for QGIS2.10 (as a dialog). When I press the ok button (if result == QtGui.QFileDialog.Accepted:) everything works just fine but the gui is disappeared. How can the gui ...
5
votes
1answer
117 views

Create a temporary intermediate layer in a processing script

My algorithm needs a temporary layer in a QGIS processing script. I can use regular pyqgis api to create a temporary layer but want to know if there is a preferred and processing-specific way of doing ...
1
vote
0answers
70 views

Creating spatial layer from MS SQL Server table?

I have a table in MSSQL that I am trying to use to create a spatial layer from using the QgsVectorLayer function to load the table as a layer, and then using Fiona to create a shapefile but I am ...
0
votes
0answers
63 views

GDAL error in QGIS application displaying VRT files

I am working with a standalone app build with QGIS 2.8.1 on a CentOs7 machine. I got a new DTED data set which raises errors "somewhere" in the app. The app doesn't read the .dt? files directly, but ...
4
votes
1answer
152 views

Converting Python script for QGIS?

I am still a novice in python, but I have the long term goal to create a plugin one day. The first step to this plugin is a test with QGIS python scripts to convert an Access mdb into sqlite db and ...