Python bindings for QGIS.

learn more… | top users | synonyms

4
votes
1answer
336 views

How to add a layer group using pyQGIS?

Good morning, I would like to know how I can create a new group in the layer manager using python code, someone could help me?
3
votes
1answer
77 views

Access ESRI .GDB in PyQGIS

I can access ESRI .GDB data using OSGeo's OGR. The following code gives feature class names embedded in .GDB... from osgeo import ogr driver = ogr.GetDriverByName("FileGDB") data = ...
4
votes
2answers
449 views

Load and display a layer using PYQGIS

I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
0
votes
0answers
22 views

Is there any alternative for reshapeGeometry in Qgis 2.4 version

I am splitting the polygon feature if it intersects with the line feature. I am using reshapeGeometry() but it is nt wrking in qgis2.4. Is there any alternative to use for this one.it is wrking ...
1
vote
2answers
20 views

QComboBox nested within a Qmenu?

Is it possible to nest a QComboBox inside of a Qmenu within QGIS? Below is my current code and an associated screenshot with the unexpected results. (orange = current incorrect placement, green = ...
1
vote
1answer
17 views

QGIS plugin select and edit features performance issues

I wrote a plugin for selecting and instant updating the value of the selected feature in the attribute table. I tested with a big shapefile and to select and edit 5 features takes ~5 seconds. Which ...
3
votes
2answers
48 views

Azimuthal orthographic projection QGIS2.6

I'm trying to create a globe view in QGIS2.6 with an Azimuthal Orthographic projection using NaturalEarth's 110m countries dataset. I'm following Hamish Campbell's blog post instructions that have ...
3
votes
2answers
639 views

How to debug 'Layer is not valid error' from Python plugin?

I'm trying to understand what goes wrong with a QGIS python plugin. Basically I'm trying to render a series of POINT. The query works fine, at least giving it by hand from inside PostGIS DB: "SELECT ...
1
vote
1answer
57 views

How to move a layer in QGIS Toc above an existing group?

If in QGIS TOC a group already exists and I add a new layer via QgsVectorLayer* lyr= mQGisIface->addVectorLayer(uri->uri(),Title, myProviderName); the new layer will be inserted within the ...
0
votes
1answer
44 views

How to draw perpendicular/Parallel line using pyQGIS?

While digitizing a line with multiple segment, how to create a particular segment parallel to (or) Perpendicular to another feature using pyQgis?
1
vote
1answer
38 views

How to customize the QGIS default GUI using Python?

Is it possible to hide/remove/customize the default ui of qgis using python plugin. I want to add my own menus and toolbars and remove default. If it's possible, which reference should I use?
5
votes
1answer
366 views

QGis Zonal Statistics Plugin NoData included in Calculations

I have been trying to use the QGIS zonal statistics plugin. My raster has a nodata value of -99999 and all other values are positive. After computing the mean zonal statistics there are a number of ...
2
votes
2answers
104 views

Get Index for a group QGIS Python

I am trying to add new layers into a specific group which I can get to work if I know the index but how can I get python to fid the index of a group so it can load the new layer into the group ...
3
votes
1answer
946 views

legend groups and layer position/order qgis 1.8

I'm tring to programmatically create layer sequence also using groups. Simple python code: layer = QgsVectorLayer("004cp000.shp", "004cp000", "ogr") QgsMapLayerRegistry.instance().addMapLayer(layer) ...
3
votes
1answer
140 views

Programmatically change layer position in the table of contents (QGIS)

I am trying move/position a layer to the bottom of the TOC by using addTopLevelItem on all other layers. I unsure how to reference the layers as QTreeWidgetItem's. def bg_bottom_level_item(self): ...
3
votes
2answers
385 views

How to add layer/raster with specific position in the QGIS layer list?

I use addRasterLayer(rast,'Name') but this adds the raster to the top. It is possible to set position when I add raster at once? Is it possible??
2
votes
2answers
124 views

pyqgis: AttributeError: 'QgsRasterLayer' object has no attribute 'drawingStyle'

qgis gurus. I have a question about pyqgis and hopefully I can get some advise here. I am following http://www.qgis.org/en/docs/pyqgis_developer_cookbook/intro.html. In python console after a raster ...
4
votes
2answers
1k views

Setting the extent for a QGIS map using python

I am writing a stand-alone application in Python/QGIS that simply creates maps. I want to load vector/raster layers, set symbology, set extent At the moment, that is all! Currently I am just using ...
0
votes
0answers
15 views

Make qgsmapcanvas.extent().size equal to qwidget.size()

I am using Qt and QGIS to write a touch device application. Right now, I have a QWidget which is the child of qgsmapcanvas, and both of them are full screen. However, the qwidget size is (1920,1080), ...
1
vote
2answers
154 views

Save a layer for each unique value using Python in QGIS

I have a map, in which each region is defined as an attribute of the map (I can select each region from the attribute table). I am trying to create new layers each one containing only 1 region using ...
2
votes
2answers
60 views

How to programmatically create nested layer groups?

Using PyQGIS via the QGIS 2.4.0 Python console and the editor, I can create parallel groups for storing some layers with: MyFirstGroup = iface.legendInterface().addGroup('Group No. 1') MySecondGroup ...
1
vote
0answers
16 views

How to show combine results or export them with PyQgis

I'm quite new in Pyqgis and i think Pyqgis could make my work easier. I first want to try with a simple code, here is what i want: merge some features and then export them in a shape files. For the ...
1
vote
1answer
49 views

QGIS install on Ubuntu 14.04 fails

Following the QGIS installation guide I have tried both UbuntuGIS and QGIS stable, but both fail with the error message: The following packages have unmet dependencies: python-qgis : Depends: ...
3
votes
1answer
66 views

clip geometries in postgis table if they are inside a polygon

I have polygons defined in KML files just like this one, which I can easily parse. Example: <Polygon><outerBoundaryIs><LinearRing><coordinates> -91.463940,40.372660,0 ...
0
votes
1answer
33 views

QGIS plugin select and edit feature attribute [closed]

I'm looking for a QGIS plugin that can change attributes (attribute table) of features on a vector layer by selecting them with the mouse. I found this plugin "SelectTools": ...
0
votes
1answer
23 views

Adding geometry to QgsVectorLayer with lon/lat coordinates

I'm creating a custom Qt app that uses pyqgis for showing data on maps. I have successfully created a map canvas that shows a world map from a WMS server. Now I'd like to overlay data on this map. ...
0
votes
2answers
129 views

Error while importing CSV File using PyQGIS

Currently I am trying to import a CSV file using the python extension in QGIS and I have run into a problem that I can not seem to solve. I am trying to do a basic import of a CSV file from a python ...
1
vote
0answers
32 views

Why must I write `geometryType() == 3` for point and polygon shapefiles?

I am asking this question based on the result I received from this earlier post. The following script only works if I set geometryType() == 3 as that is what is being printed out in the Python console ...
4
votes
2answers
238 views

How to identify polygon/point shapefiles in python?

I have a script which performs various functions on shapefiles, most of which are polygon-based. However, some shapefiles are point-based and I have to specify where these files are by editing the ...
2
votes
0answers
32 views

Using pdb in QGIS console

I am unable to use pdb from qgis console. If I run a function that calls pdb.set_trace() I get the error Traceback (most recent call last): File "<input>", line 1, in <module> File ...
1
vote
1answer
31 views

align scale bar with PyQGIS

I am making several maps from a template with a PyQGIS script and I am having problems to align the scale bar on them. My code is: # create scale bar item = QgsComposerScaleBar(comp) ...
1
vote
0answers
29 views

PyQGIS: standard and advanced linear referencing possibilities

I'm aware of the existence of the following QGIS plugins: QChainage Event layer linear referencing LRS Although, all of these tools offer some linear referencing capabilities, I find that they ...
0
votes
2answers
529 views

How to display data from a feature?

I want to display data based on the feature currently selected/clicked on. I am following a tutorial from http://www.qgisworkshop.org/html/workshop/plugins_tutorial.html. It initially shows you how ...
2
votes
0answers
17 views

PyQGIS: Using a Simple Coordinate System (Cartesian Space)

Is there a built in non-world coordinate system that represents simple cartesian space? I want to use PyQGIS but have a canvas set with 0,0 origin and infinite planar space in each direction. In ...
2
votes
1answer
34 views

Is there a python version of qTuio? [closed]

Is there a python version of qTuio? qTuio is implemented in C++. However, I am currently trying to use pyqgis due to problems with C++ environment (I cannot even create a raster layer). Any help is ...
0
votes
1answer
27 views

PyQgis Diagram Automated Placement Engine

I am trying to programatically change the "Show all labels and features for all layers" option for a layer which display diagrams. This option doesn't seem to appear in QgsDiagramRendererV2 api. It ...
0
votes
0answers
15 views

Handling event in overlap widget scenario in Qt

Here is my problem: I am trying to develop a mobile application using Qt and QGIS in python. I am trying to mockup zoom action on qgsmapcanvas. Right now, I have a qgsmapcanvas and a qwidget. I ...
2
votes
1answer
97 views

How to print 2 maps in the same PDF page using PyQGIS?

I am trying to generate a one-page PDF document containing the following items: 1) On the left half, a full state map (say, New York State). 2) On the top right quadrant, a map that zooms in to one ...
8
votes
1answer
177 views

How to call the interpolation plugin from the python console?

I would like to call the QGIS interpolation plugin function (TIN method) (Raster->Interpolate) from python console. I can't find the corresponding function within QGIS API or within the ...
2
votes
2answers
69 views

Saving a QGIS project using the API loses mapcanvas (and other) XML nodes

I'm using the following python script to open a QGIS project, modify some things, and save it under a different name: from PyQt4.QtCore import QFileInfo from qgis.core import * def main(): ...
1
vote
0answers
22 views

Interpolation plugin from PyGIS? [duplicate]

How to run this plugin from PyQGIS?? http://docs.qgis.org/2.2/en/docs/user_manual/plugins/plugins_interpolation.html
3
votes
2answers
166 views

Is there a function to select a region of a map for further processing with Python?

I would like to select a map's region in QGIS for further processing with python console. Ideally I would like to select the region with a mouse drag (like Gimp crop function) and then e.g. analyze ...
1
vote
0answers
28 views

How to exit the QDialogBox button in qgis using python programming

I have created a dialog box with ok and cancel buttons.But i want one more exit button where it has to exit the QdialogBox. When i am using exit()it is exiting the complete qgis but i want to exit ...
1
vote
2answers
55 views

What are QGIS Arcpy Equivalent Functions for MakeFeatureLayer and SelectLayerByLocation?

I have a script that I had created using ModelBuilder, but our field personnel use QGIS 2.0. Below is a snippet of the code. I am wanting to know if there is an equivalent using pyqgis so that I can ...
2
votes
2answers
114 views

PyQGIS: How to send signal if layer is currently in edit mode

I'm looking for a way to send a signal if a layer is in editing mode. I tried editingStarted(), but it wasn't working. I'd like to do something along the lines of the what I have below, but can't find ...
2
votes
1answer
108 views

Setting up pycharm and pyqgis

I wanted to set up PyCharm the way this blog post explains: Setting up PyCharm for PyQGIS and Qt. I did everything as instructed but when it comes to adding project interpreters I got this error ...
0
votes
1answer
31 views

PyQGIS export to JSON: writeAsVectorFormat and precision

In my QGIS plugin qgis2leaf I am exporting all layers as JSON into a JSON directory. Therefore I would like to enable the user to define the precision in the GUI. The normal "save as" dialogue in QGIS ...
1
vote
0answers
24 views

How to get the last edited feature id using python

After merging the two features in the polygon the feature id will be changed for the merged feature after committing the changes. So how do i get the feature id of the merged feature or the last ...
2
votes
1answer
299 views

pyQgis in stand alone script, vector loading error

I am trying to use the Qgis functions in a stand alone Python script. I m running Mountain Lion OS, 2.7 Python & the Qgis 2.0.1 Dufour. My main problem is that I cannot get started - I cannot ...
1
vote
1answer
23 views

How to switch rule-based styles in loop?

I'm a working on a QGIS script that could activate/deactivate rule-based styles of the vector layer in a loop (one active layer per iteration). On the every iteration this scenario should: Activate ...