Python bindings for QGIS.

learn more… | top users | synonyms

0
votes
1answer
34 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?
0
votes
1answer
24 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
364 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
938 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
139 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
379 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??
1
vote
1answer
47 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 ...
2
votes
2answers
123 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
14 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
153 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
15 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
37 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
60 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
28 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
22 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
232 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
31 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
29 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
28 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
527 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
14 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
77 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
172 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
68 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
164 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
26 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
113 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
99 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
27 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
298 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
22 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 ...
1
vote
1answer
135 views

How to save after using fet.setFeatureId in pyQGIS?

By using the following code, I want to change the id of the line when saving the line. But the setFeatureId command, gives a false when doing the commitChanges(). Any idea how to change the id? vl = ...
1
vote
0answers
25 views

How to open a second window in QGIS plugin from a button inside the main window

If I already created a qgis plugin, and i need to create a button inside that plugin that opens a new window, how is that possible? Qt creator won't add a slot unless there are a header file. I looked ...
2
votes
0answers
32 views

How to load all items from a template with pyQGIS in QGIS 2.6

Since QGIS 2.6, the LoadFromTemplate method seems not work any more (or works differently?) This is my code to add items in my composer from a template : self.composition = ...
0
votes
1answer
18 views

Read ellipsoid parameters

I would like to retrieve the semi-major axis of ellipsoid of a layer (any layer) using Python API. It seems that crs class can read only the ellipsoid acronym (?) Apparently, QgsDistanceArea class ...
1
vote
1answer
147 views

How can I add grid lines to a print composition using pyqgis?

I'm writing a qgis plugin to create an image in the print composer of the current map. I can get the map rendered in the proper place with a frame of the right width, and I can get grid annotations ...
6
votes
2answers
497 views

How to write scripts that can call on both Arcpy and PyQGIS?

I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script. Parts of answers have been ...
3
votes
2answers
63 views

PyQGIS: Speed up for adding features and attribute arrays?

Context: I'm writing a dynamic import tool for QGIS (2.2 to 2.5) with python. Datatype: Binary Datasets with environmental simulations from HPC which might contain millions of features and terabytes ...
2
votes
1answer
245 views

Why shapefile loaded in canvas always appear in random color?

I created the simple frame .UI file, compiled with pyuic4, and tried the ShapeViewer.py to load the shapefile "world_borders.shp". However, the map is always loaded in different random colors every ...