Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
0answers
21 views

Why PyQt http request works in QGIS console, but not in a plugin?

I want to send http request in a QGIS plugin using PyQt. I found in this post working syntaxes to do so, but something odd occurs. The script given in the question works both in the console and in my ...
0
votes
1answer
24 views

Couldn't destroy QGIS Custom Edit Form Factories

I created custom form factories using this tutorial. However, the factory destructor QgsEditorWidgetRegistry(). However, it doesn't destroy them. I just used the above destructor at the beginning of ...
2
votes
1answer
28 views

syntax for selectbyexpression MTFCC in pyqgis

Does anyone know the correct syntax for the selectbyexpression processing algorithm for selecting MTFCC's? This is what I have right now, but it doesn't work so I'm guessing my problem lies in the ...
3
votes
0answers
47 views

QGIS QgsAttributeTableModel only loads when called without a function in Python

I tried to load QgsAttributeTableModel into QgsAttributeTableView or a plain Qt QTableView but it could run from inside a class method or function but it runs without any function or method. Below is ...
1
vote
0answers
14 views

How do you test QgsDataSourceURI.setConnection is valid in a QGIS plugin?

I am currently trying to write my first Python plugin for QGIS and I'm using the the uri = QgsDataSourceURI() uri.setConnection(host,port,db,username,password) syntax to create a connection to an ...
1
vote
1answer
24 views

How do I control the behavior of the QMessageBox

I'm working on my first plug-in. In an attempt to validate the user selections on the dialog, I am using a message box to return messages to the user if an error is found. The messgae box displays ...
2
votes
1answer
32 views

Separating a shapefile with specific features into a new shapefile using PyQGIS

I have a shape file. I would like to know if it is possible to classify the different layers in that shapefile (like highways, local roads, rail lines, etc.) with MTFCC and extract a separate ...
1
vote
0answers
26 views

PyQGIS: gdalogr:cliprasterbymasklayer new options?

I have had used gdalogr:cliprasterbymasklayer function in PyQGIS many times before but with the latest update there seems to be a lot more extra arguments and I can't figure out how to get the ...
2
votes
2answers
64 views

Save line geometry as points geometry in QGIS (pyqgis)

I have line and polygon layers. I want to make a list of points' coordinates (ends or begginings of lines), which are touching the polygons. The coordinates which I need are selected as yellow. ...
2
votes
1answer
18 views

pyQGIS - set grid annotation direction 'Vertical Descending'

I am using pyqgis to create map automatically. However I encounter a problem when I want to set the grid annotation direction to 'Vertical Descending'. The command I use is the following: composerMap....
0
votes
1answer
47 views

Initialize Remote Debug (QGIS Plugin) for Eclipse (PyDev)

I have used the following guide: http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/ide_debugging.html#debugging-using-eclipse-and-pydev I have installed the plugin (PyDev) under Eclipse (...
1
vote
0answers
25 views

Use Function V.clean of the grass tool in a script pyhton

I need to integrate V.clean functionality of Grass in a script python. this functionnality is accessible in Qgis (Processing->tools). I found that I should use Grass API but I don't know the code ...
1
vote
1answer
16 views

Adding all the layers in a KML file in PyQGIS

I've a KML file that contains several layers, if I use the usual method of adding vector layers from a file it only adds the first layer (the Point layer) vlayer = QgsVectorLayer("C:\Users\HOME\...
2
votes
1answer
46 views

Cluster analysis using buffers and polygon features (NOT layer)

I have a point-based vector layer, where each point represents a road accident. I am trying to write a function that: Loops through my accident layer creates a buffer, of a given radius, around each ...
3
votes
1answer
29 views

Programmatically animate objects on canvas to change color by delay

On my map canvas I have various point objects spread through several layers. My plan is to 'animate' those objects by a loop from start to a predefined resolution. By now I'm just testing the ...
0
votes
1answer
41 views

Load a specific spatial data from a postGIS table

A single postGIS table contains multiple type of spatial data(example: Linestring,Polygon,etc.,). How to load a specific spatial data from PostGIS table into QGIS by using pyqgis?
2
votes
1answer
32 views

Most efficient way to select a given layer programmatically in QGIS

this a question about code efficiency, not asking how to loop through layers. I'm getting the 'this question appears subjective...' warning but there must be a tried and tested method by someone more ...
1
vote
0answers
20 views

How to replace QGIS featureAtId() with getfeatures()?

I'm trying to upgrade a script made for QGIS 1.8 to work at version 2.14 One of the problems I face is that the featureAtId function at 2.14 is now obsolete. Original codes looks like this. ...
0
votes
0answers
16 views

Load a pre-defined legend into MapCompser programtically with python

Is there a possibility to load a predefined lendend into the MapCompser with python? I want to use instead of createLegend(...) (..see below) something like def loadLegend(file): .... def ...
1
vote
1answer
19 views

Connect Qt DoubleSpinBox to PyQGIS script

I have done a python script and I want to change the '1.0' value on pas15 with the value that is set in the double spin box, but I can't find the way to do it. Any idea? self.dlg.doubleSpinBox....
1
vote
1answer
44 views

PyQgis create labels

I am creating a QgsVectorLayer in a plugin and loading it into the map. I would like to set the labelling parameters while I'm doing that. I've followed several examples found here and here, but my ...
1
vote
1answer
45 views

How to implement layer.setEditType for custom widgets in QGIS?

How could I use layer.setEditType() method in QGIS for a custom form widget? Cusom form elements are well explained by Matthias Kuhn here. I was able to change the existing default widget types. For ...
0
votes
0answers
46 views

Read a vector layer from a Postgres/PostGIS database via a SQL query with QGIS and ogr in a python script

I have a treatment table for different aggregation stategies on a geospatial table in a PostgresSQL/PostGIS database. The aggregation strategies addressing temporal and species specific pre-selections ...
2
votes
1answer
56 views

pyQGIS merging shapefiles

I've been searching the internet for a while now trying to look for a way to merge all the shape files from a directory (a folder) into a single shape file. I found many solutions but none of them ...
0
votes
1answer
21 views

How to update attributes on spatialite table programmatically: SQLite Error

I am writing a plugin that updates 2 fields in an existing spatialite layer. The spatialite table contains several layers which are displayed on the current map. It executes to completion (very slowly)...
3
votes
0answers
45 views

Python QGIS crashes within categorized renderer setup

I'm hassling around with QGIS renderer definitions in python with QGIS 2.8 at debian wheezy. At least I want simply build step by step a categorized renderer to fill a polygon. The script crashes, ...
4
votes
2answers
96 views

QGIS doesn't update some snapping options from Python

I've just installed QGIS 2.14.3 (Essen) on a Windows 7 machine, so I've got the default configuration on everything. This means that under "Settings -> Options -> Digitizing", I've got "Default snap ...
1
vote
0answers
34 views

Getting error message “An error has occurred while executing Python code: ZeroDivisionError: float division by zero” [closed]

I am getting the following error while executing Python code: An error has occurred while executing Python code: ZeroDivisionError: float division by zero Traceback (most recent call last): File "...
1
vote
1answer
30 views

Run processing (GRASS) algorithm as administrator

I am trying to use GRASS algorithms in a plugin of mine, in order to improve the quality of a shapefile containing lines that will be used as a graph later. The first algorithm I want to use is the ...
1
vote
0answers
9 views

Switch QGIS proxy settings programatically

I am using QGIS at two offices with different proxy-servers. At the moment I have to change the proxy settings manually every time i switch the office. I was wondering if its possible to change the ...
2
votes
1answer
58 views

Add multiple rasters using QgsRasterLayer with for loop

I am trying to create a for loop for coloring up multiple rasters simultaneously. I am able to do it for one layer, but trying to implement the for loop to do it for more than one layer is proving ...
0
votes
0answers
14 views

Qgis Server error while loading wms layer in qgis

I have created qgis server by following link http://hub.qgis.org/projects/quantum-gis/wiki/QGIS_Server_Tutorial and http://docs.qgis.org/testing/en/docs/user_manual/working_with_ogc/...
2
votes
3answers
111 views

No Module named qgis

I installed QGIS through OSGeo4W, and I am trying to write a standalone PyQGIS script, however, I am unable to import the qgis, qgis.core, processing ect… modules, as shown in the picture, I get the ‘...
2
votes
1answer
47 views

QGIS geoprocessing scripts, default values for field names

In QGIS geoprocessing scripts, default values must be provided for input numbers and strings, according to http://docs.qgis.org/2.8/en/docs/user_manual/processing/console.html#creating-scripts-and-...
1
vote
1answer
56 views

How to load html file with leaflet map using PyQGIS

I have simple .html file with leaflet map layers. I want to load these layers in QGIS mapCanvas with ability to choose one of the layers. How can I load this .html and show one of map layer with using ...
1
vote
0answers
13 views

How to write CRS info from QGSVectorLayer

I'm writing a plugin which will create a new virtual layer containing points. I know the CRS of the new layer, as it is the same as the layer I am using for input. I would like to specify the CRS in ...
2
votes
1answer
18 views

SyntaxError with custom function using QgsFeatureRequest.setFilterExpression

def get_subsel(layer,filter): layers = iface.mapCanvas().layers() for lyr in layers: if lyr.name() == layer: request = QgsFeatureRequest().setFilterExpression(filter) ...
0
votes
0answers
28 views

qgis python + layout/template + exporting in .png + filtering layers

Such a problem. I need to do a lot of pictures at different points from vector layer on each. And the picture (.jpg / .png) must be signed and so on - then the layout is best suited. Now I do a ...
3
votes
0answers
54 views

How to handle large tables in QGIS using python?

I'm currently writing a plugin that calculates values based on a QgsVectorLayer's attributes. To display and print the values I'm using a QgsComposerTextTableV2. I have several problems with my ...
0
votes
0answers
32 views

How to capture the event whenever the items inside the listview is enabled or disabled and get the number of enabled checkboxes inside the listview

I have a function "openBrowse" which will allow the user to select SQL files from a local path and display the file names as with dynamic checkboxes created based on the number of files selected ...
1
vote
0answers
29 views

Open raster and vector files with PyQGIS

I'm making a plugin for QGIS and I'm trying to open the layers I've created on QGIS, but I only get to open the one called 'sinkhole raster' which is the input of the tool. I don't know what order ...
1
vote
0answers
22 views

Creating layout in Python for QGIS?

How can I create a layout and import it into .jpg or .png format? This code: from PyQt4.QtCore import * from PyQt4.QtGui import * from qgis.core import * from qgis.gui import * # ...
2
votes
1answer
83 views

How can I change the origin (top left corner) coordinates of a raster using PyQGIS?

I am developing a python plugin for QGIS. The purpose of the plugin is to properly open an HDF5 dataset as a raster. Opening and displaying the raster can be done without the need for a plugin, ...
5
votes
1answer
111 views

How to define border colour for rule-based style using PyQGIS?

I use the following to create a Rule-based style for a given layer which includes defining a label, expression and colour fill: from PyQt4.QtGui import QColor layer = qgis.utils.iface.activeLayer() ...
6
votes
1answer
149 views

How to close/remove QGIS welcome page (recent projects) with Python?

Is it possible to close the QGIS welcome page with Python? I have a permanently docked Python plugin, that uses showRubberBand to directly write into map canvas. Therefor I have to close/remove the ...
2
votes
1answer
80 views

QGIS Filter layer by expression [closed]

Can I make the filter by the value that is obtained by the function? for feature in iter: name_dot = feature['name'] print name_dot expr = QgsExpression("\"name\"=name_dot") selection= layer....
2
votes
0answers
26 views

Importing submodule with python for QGIS?

So I am probably missing something really obvious here, but for some reason, I can't import submodules in my python plugin. This is the general structure of my plugin: ├── __init__.py ├── metadata....
1
vote
1answer
80 views

Dynamically move map canvas and main window using PyQGIS

I am trying to create plugin that will open new window with some layer, Dynamically "pan" my window, when main window is pan. So boundingbox coordinates should be the same in both windows. I need new ...
2
votes
0answers
29 views

Finding vectors with wrong direction in river network

I have a shapefile containing network of rivers for the whole country. The description of the layer is saying that orientation of the vector should be the same as the river flow. This is true for most ...
3
votes
1answer
75 views

Python to create new fields in many layers / QGIS

I have a number of line layers on which I need to perform the same task: add 4 columns with the start and end points of each line. The expressions that I use to do this are: $xat(0) $xat(-1) $yat(0) ...