Python bindings for QGIS.

learn more… | top users | synonyms

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?
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
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 ...
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?
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: ...
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": ...
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
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. ...
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 ...
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
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 ...
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) ...
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
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
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 ...
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
2
votes
1answer
78 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 ...
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
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 ...
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
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
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
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 ...
1
vote
1answer
44 views

How to calculate the perimeter of the polygon using python programming

Is it possible to calculate the perimeter of each feature of the polygon? For calculating the area we are using: area=feature.geometry().area() is there any function to calculate 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
1answer
83 views

How to add vertex to an existing polyline programatically?

I have a Polyline and would like to add new vertex to before start point or end point or at any part of the polyline using python in qgis. How can i do that?
0
votes
1answer
25 views

With QGIS Plugins/PluginBuilder, how to prevent 2nd instance of Plugin from starting

I am using QGIS 2.6.0, with PluginBuilder 2.0.3 [checking the version, I just noticed that the 2.1.0 update is available] I am writing a plugin; it installs and runs. While running, I am able to ...
2
votes
0answers
33 views

Add button to custom standalone QGIS application

Im able to implement zoom in and zoom out functionality as described in the PyQGIS developer cookbook using a tool bar. I would like to have buttons that display above my map canvas layer and have the ...
2
votes
1answer
91 views

How to prevent users to remove qgis layer?

I need to prevent users from removing layers. In my plugin code I use the following to achieve that: QgsMapLayerRegistry.instance().layersWillBeRemoved.connect(self.dontremovefunc) def ...
1
vote
2answers
43 views

Using QgsRasterCalculator

I'm trying to make a sum of n rasters and create a new one using QgsRasterClaculator, the problem is, every time the code reaches processCalculation, it makes QGis close and create a dump file. I ...
0
votes
0answers
43 views

How to find a distance from a point to a polyline in QGIS?

Please show a sample Python code of finding a distance between a point to a polyline in QGIS. (without any plugin)
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

Add ids to the merged features using python programming

I have written the python code that merge the features based on the area.But after merging the features it is not assigning ids to the merged feature.Can anyone tell me how to assign ids to the merged ...
2
votes
0answers
64 views

PyQGIS cookbook seems out of date

I am trying to follow the http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/ but it seems to be out of date, for example many of the raster methods no longer work as indicated or even ...
2
votes
1answer
97 views

How to create a Qgis python script to manipulate fields with some parameters?

I'm just beginning with QGIS. I have a shape file with 10 fields field1, ..., field10, and many thousands of data. I will like to automatize the next sequence (in a python script or a model): load ...
2
votes
2answers
115 views

Programatically use Openlayers plugin layer in Print Composer

I created some PyQGIS functions to set up a print composer, modify the layout (adding maps, legend, title...) and print the result as an image file. This works fine with one or several vector layers - ...
1
vote
0answers
68 views

How to overlay Google Map in a standalone PyQgis application?

I have created a standalone PyQGIS app (within Python itself, not a plugin) with PyQt and PyQGIS API. It generates my map really well. I would like to overlay a Google Map layer as base map just like ...
0
votes
1answer
20 views

How to show QgsDebugMsg in eclipse PyDev

In the source code of QGIS, I see a lot of QgsDebugMsg line. What should I do in order to show it when debug/run my standalone application in Eclipse PyDev?
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
118 views

How to load a WMS layer using PyQGIS?

Although there are some posts on this matter, there is no answer in anyone of them. This is why I am asking it again. One post I found was Raster layer invalid I read information from the following ...
1
vote
1answer
51 views

Use QGIS Gui's predefined colorramps in Python console / PyQGIS

When using the QGIS Gui, there are plenty of predefined colorramps to choose from when styling a layer with e.g. categorized symbology. When using the Python console for PyQGIS scripting, this page ...
0
votes
1answer
52 views

PyQGIS setSubsetOfFields function in QGIS 2.4

I found the function setSubsetOfFields to filter fields in a layer in the PyGIS cookbook: ...
1
vote
0answers
74 views

Apply graduated symbology renderer works in Python console but not in standalone script

I use the following PyQGIS script to load a vector layer from a shapefile and apply graduated symbology to it (tried to make it as minimalistic as possible). This works well in the QGIS 2.4 Chugiak ...
3
votes
3answers
86 views

Drawing some points in QGIS 2.4 using Python

I'm new to PyQGIS so here goes: Give a new QGIS project, how can we draw some Points on the map? I tried the following but nothing showed up. Should they be placed in a Vector layer before they can ...
0
votes
1answer
55 views

Programmatically Select a CRS in QGIS 2.4 using Python

When you run the following Python code in the Python Console of QGIS 2.4, uri = "file:///C:/data.csv?type=csv&xField=lng&yField=lat&spatialIndex=no&subsetIndex=no&watchFile=no" ...
2
votes
0answers
28 views

How to make added toolbar buttons exclusive?

I've added a toolbar to the QGIS mainWindow. Also I've added some checkable buttons to the toolbar. How can i now make my checkable buttons untoggle on QGIS default toolbars' checkable buttons press ...
1
vote
1answer
51 views

Use QGIS plugins in custom standalone application [duplicate]

I am trying to create a QGIS custom standalone application. I want to add the Google Physical map from OpenLayers plugin to my application when it starts, but I cannot seem to be able to access ...