Python bindings for QGIS.

learn more… | top users | synonyms

1
vote
2answers
29 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 ...
0
votes
1answer
16 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
140 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
465 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
55 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
234 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 ...
2
votes
1answer
30 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
2answers
815 views

QGis 2.0.1 mapserver extension missing

I tried to export my Qgis projects to mapserver, using RT mapserver extension, because there is not any other extension in my version of QGis.(QGis 2.0.1 Dufour on ubuntu 12.04 LTS). After installing ...
1
vote
1answer
176 views

How to clip a raster by a shapefile in pyqgis?

Currently I am working with some satellite images (grib files) in pyqgis. As I want to work only with the cells in my study area, I need to clip the raster by a shapefile. I know I can do this by ...
0
votes
1answer
19 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 ...
1
vote
1answer
30 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 ...
1
vote
1answer
66 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?
2
votes
1answer
57 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
34 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 ...
1
vote
0answers
26 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 ...
4
votes
1answer
345 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
106 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 ...
10
votes
1answer
1k views

How to draw perpendicular lines in QGIS?

I have a situation like this: What I need to do is to connect each point to every line that is at most, let's say 200 m, away from the point. In other words, I need to draw a perpendicular line ...
0
votes
0answers
16 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
37 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)
1
vote
1answer
93 views

QGIS GUI Python Editor Code Running Exception

import sys from PyQt4 import QtGui class MessageBox(QtGui.QWidget): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.setGeometry(300, 300, 250, 150) ...
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 ...
1
vote
0answers
55 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 ...
0
votes
1answer
48 views

Filter MapComposer legend to only show layers visible on the map

I have written a function in Python / PyQGIS (no standalone application, so copy/paste it to the Python console editor to run it) that takes a VectorLayer as argument, creates a MapRenderer object for ...
3
votes
2answers
382 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 ...
2
votes
1answer
85 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
1answer
602 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
2answers
28 views

QGIS 2.4 crashes when symbolizing QgsComposerShape in Python with ScriptRunner

I'm attempting to use ScriptRunner to output a jpeg of a red rectangle using QGIS Composer to understand the QgsComposerShape. Everything works except QGIS crashes when the symbol is applied. The ...
2
votes
1answer
98 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 ...
0
votes
2answers
508 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
2answers
89 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 - ...
0
votes
2answers
108 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 ...
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 ...
2
votes
1answer
437 views

How to create a QGIS action which copies features between layers?

i tried (i never tried before...) to write a simple python code like action in QGIS on my "XXX" vector layer that: open a layer "YYY" copy the selected feature on my "XXX"layer paste the selected ...
1
vote
1answer
62 views

WMS layer in a QGIS 2.4 stand alone Python script

What is the best way to add a WMS layer on a map, in a stand-alone python script with QGIS 2.4? The methodology explained at the bottom of the official QGIS documentation page seems to be outdated and ...
0
votes
0answers
50 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
13 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?
1
vote
1answer
42 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 ...
1
vote
3answers
155 views

How to Project a point on feature in PyQgis?

In Arcgis IProximityOperator.QueryNearestPoint Method was available to get the nearest point. Similarly Is there any function available in pyQgis? Thanks in Advance.
1
vote
1answer
207 views

How to find the polygons bordering a feature programmatically with qgis?

Is there a way to calculate the neighbors of a polygon with pyqgis for every feature? For example, the selected polygons relative to the one in the center: I found this solution, but it's a year ...
1
vote
1answer
109 views

Calculating distance between latitude and longitude by using python

I have a database of 2000 points, which is in csv format of latitude and longitude. I want to find distance between these points all at once. And also showing these points in Map by using only pyQGIS. ...
0
votes
1answer
46 views

PyQGIS setSubsetOfFields function in QGIS 2.4

I found the function setSubsetOfFields to filter fields in a layer in the PyGIS cookbook: ...
4
votes
1answer
94 views

Why are my calls to SAGA routines in QGIS not working cross platform?

The ability to write and run cross platform scripts for QGIS using python is OUTSTANDING! However, when I try to run the SAGA:MERGESHAPESLAYERS algorithm from a python script it works fine in windows ...
4
votes
3answers
380 views

How do I specify the position, style and units of the ScaleBar in pyqgis?

I would like to add a scale bar to my composition using the python console and then export it to a raster image. I am following the MapRendering tutorial with the "output using map composer " approach ...
2
votes
1answer
288 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 ...
0
votes
1answer
356 views

Code works on python console in QGIS but same doesn't work in stand alone script

I'm trying map rendering with stand alone script, so I have small script which works fine in python console provided QGIS, however when I run same code in stand-alone script it executes without error, ...
1
vote
1answer
76 views

Use PyQGIS to import CSV and draw points using different color

A CSV file contains columns latitude, longitude and color. uri = "file:///C:/data/balls.csv?type=csv&xField=longitude&yField=latitude&spatialIndex=no&subsetIndex=no&watchFile=no" ...
1
vote
0answers
52 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 ...
2
votes
0answers
27 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 ...
3
votes
3answers
76 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 ...