Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
0answers
52 views

Loading a qgsproject when another one is loaded

I am loading a project with: QgsProject.instance().read(QFileInfo(path)) When i try to load another project it subtracts the layers and shows nothing. But if I try doing it again it works.
1
vote
1answer
36 views

wrapped C/C++ object of type QgsGeometry has been deleted ubuntu and mac and segmentation fault

I have a problem with a specific method in qgis 2.8, 2.12 and 2.12.1 on linux and mac (I have not idea if in windows this problem persists) The example: from qgis.core import * from qgis.utils ...
4
votes
1answer
83 views

How to use third-party package in a QGIS plugin?

I'm developing a QGIS plugin and I would like to use arrow or requests packages as I'm used to manipulate dates and REST APIs. QGIS does not come with these packages (at less arrow), so when I try to ...
4
votes
0answers
40 views

See python script running while processing a task in QGIS?

Is it possible to see scripts running in Python Console - everything from tools and analysis vector to raster?
3
votes
1answer
124 views

Set selection color transparent and border color red in QGis using python

I have a layer with different informations. I want to change the selected polygon color to "Transparent". I am able to achieve that using: iface.mapCanvas().setSelectionColor( QColor("Transparent") ) ...
2
votes
1answer
45 views

Populate combobox with postgis layers

I'm new to pyqgis/python and programming in general.. and i am working on my first small project. I want to create plugin so that I can add layers from my PostGIS database to a QGIS project. I ...
1
vote
0answers
35 views

Label layout on python in QGIS

Now the only issue is that in image I am not getting the labels, I have on polygon. Please help in that too Please see above attached screenshots here I need labels – I have updated QGIS it's version ...
4
votes
1answer
65 views

Rename field QgsField is not valid

In pyQGIS i tried this code (contains also debug prints): def joinLayers(inputlayer, layer, index_field, name = "JOINED", dataProvider = "ESRI Shapefile"): a = [] b = [] outpath = ...
3
votes
1answer
58 views

Layout show label and each polygon make serrated image

I want to develop "Print lay out functionality", but in output system is giving me whole image, I want to print only selected polygon. Also it is not displaying label names on print image. Please ...
3
votes
0answers
36 views

How to show only selected features from a a layer in the QgsComposerLegend?

I have developed a custom qgis plugin. I have a button to export the map canvas in the form of image along with the legend. I came up with the following code for the legend: legend = ...
5
votes
1answer
59 views

How to set keyboard shortcuts for 'Layers' and 'Browser' panels in QGIS 2.12.1 Lyon?

I have been using the python solution presented in this answer, which has worked well from 2.6 to 2.10 for me, and still works in the LTR 2.8.4. I can't get it to work with 2.12 (and recent point ...
1
vote
0answers
28 views

Manage QGIS layer table content within a plugin?

I want to embed a layer table in a plugin but it's not only for viewing but also for editing. My current code below displays the content from PyQt4.QtCore import * from PyQt4.QtGui import * from ...
5
votes
2answers
81 views

How to create memory layer and populate fields?

Seems like a basic operation using PyQGIS but can't see what I am missing. I want to create a memory layer with the exact same features and attributes from a shapefile. I have looked several posts ...
5
votes
1answer
59 views

Batch “Save as” layers w.r.t their geometry type in QGIS?

We have 100's of dgn files. We have successfully "assigned" coordinate system to those dgn files in batch by using "on the fly" + custom CRS. Now we have to save each dgn's geometry (Point, ...
2
votes
1answer
67 views

How to get perpendicular line script to work?

I'm trying to get this script to work by @gene but I'm not sure how to load the results into QGIS. I tried to make a memory layer but not sure how to add the geometries of the point, line and the ...
0
votes
0answers
22 views

Cannot retrieve attribute information from PostGIS layer

I want to develop a simple plugin and try to get started with python in QGIS. However, I have already run into troubles just loading my data properly. From the cook book Iam using the code below ...
4
votes
1answer
87 views

Updating feature attribute in QGIS plugin?

I am writing a plugin for QGIS (v2.12). There have been quite a few similar questions on this forum, but they don't seem to work for me. my plugin does the following: get the vector layer check ...
0
votes
0answers
44 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
96 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
129 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 ...
3
votes
1answer
54 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
81 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
40 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 = ...
1
vote
0answers
16 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
110 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
59 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
58 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, ...
30
votes
4answers
545 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
65 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 ...
2
votes
0answers
40 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
56 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) ...
2
votes
1answer
50 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
77 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 ...
5
votes
1answer
198 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
79 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 = ...
1
vote
1answer
21 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
29 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
112 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 ...
2
votes
1answer
69 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
97 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
48 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
48 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: ...
2
votes
1answer
64 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
26 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
14 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
151 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
51 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 ...
1
vote
0answers
31 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
60 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
220 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: ...