Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
2answers
199 views

How to delete empty fields from a Shapefile with QGIS or ogr2ogr?

I have a Shapefile with a lot of empty columns but many of them are empty. Using QGIS or ogr2ogr, how do I remove all attribute columns where everything is NULL?
2
votes
1answer
284 views

How can i use python QGis network analysis library to calculate short path based on speed and distance?

I want to calculate and show short path from starting point to an end point in a qgis python plugin. in my research i stopped by an article about QGis network analysis library; ...
0
votes
1answer
30 views

How to load a raster layer using PyQGIS?

I need to load a raster file from the provided file path. I wish to use it further in the Raster Calculator. I wrote a function which converts string (I assume it is a file path) to a raster object. ...
2
votes
1answer
144 views

Accessing CRS info with pyqgis in a standalone application

I'm currently having trouble accessing and defining CRS information in a standalone application. I've read the API documentation and have tried it in the python console in QGIS 2.2.0. The python ...
0
votes
1answer
41 views

Why is the display of QgsMessageBar delayed?

When a function is called - a file is tested for existence. This checksum pushes a messageBar() object for both circumstances (True/False), yet the actual bar does not display in MapCanvas until ...
2
votes
1answer
137 views

Loading features attributes into numpy array

I am currently working on an add-on that relies on the user choosing fields of tables (that can be from shapefiles, csv or dbf) that are open in QGIS and then making computations with such data. ...
1
vote
1answer
42 views

PyQgis, styling vector layers in different canvas

I'm developing a QGIS plugin and I need some help with styling layers in different canvas objects. In my dialog window I've got two QgsMapCanvas objects canvas1 and canvas2. Layers from registry are ...
2
votes
1answer
263 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 ...
2
votes
1answer
143 views

Import error when utilizing QGIS's Python Init function

Based on the answer to Referencing Qt UIs external to plugin with python. I'm trying to utilize the "Layer Properties / Fields / Python Init function" to execute a file (test_file.py) that is located ...
0
votes
0answers
35 views

Displaying symbology outside map canvas window extent?

Say we have equally distributed x,y mesh vector file. Each coordinate has a map-unit based diameter circle symbology. If we zoom into a region of the map canvas far enough, some centroids exist ...
4
votes
2answers
455 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?
2
votes
1answer
39 views

Tool Bar visibility in PyQGIS

I am creating a plugin for Qgis 2.6 and when my plugin loads up i want to disable the visibility of some of the tool bar. I was able to set the visibility for various tool bars like ...
2
votes
1answer
137 views

Standalone script looping incorrectly?

Following on from my previous question, I would like the script to do the following (includes illustration): Search for the first shapefile (Paris (O).shp) in Country_France > Original files and ...
0
votes
1answer
26 views

Problem calling qgis2leaf outside the QGIS

I am a computer programmer starting with PyqGis-Python, and I’d need to automatize the creation of a webmap using the plugin of qgis2leaf from a QGIS Project. I have reached to call “import ...
1
vote
1answer
39 views

How to make a Standalone QGIS application run as an exe file

I had made a simple standalone application and that works fine. But the user have to execute a batch file(inside in which I had set the QGISHOME path, Python path and call my main python file) to run ...
1
vote
1answer
15 views

How to make the toolbar icon visible in the target machine without changing the path

I had done a simple standalone application that loads a shape file and does some basic actions like zoom in, zoom out, pan etc in the viewer. In my python file, I had set the icon path for all these ...
1
vote
1answer
29 views

Viewer not displaying the data in my standalone PyQGIS Application

I tried creating a standalone external application of QGIS using python and I followed the tutorial mentioned in the link ...
1
vote
0answers
24 views

PyQgis: Load qlr files

I have a plugin that loads a Raster image and selects the correct base maps to use. The Raster image load with no problem, but my base maps will not load. I have create a qlr, which has 5 references. ...
0
votes
1answer
40 views

Standalone External QGIS Application using python [closed]

I am creating a standalone external Application of QGIS using python and i am following the tutorial mentioned in the link ...
0
votes
0answers
29 views

pyqgis - refreshing only QgsMapCanvasItems not the entire QgsMapCanvas

I have a fairly complex map, consisting of many layers, and despite they're optimized, they still take a certain time to refresh. I also have a QgsMapCanvasItem representing my position, which i would ...
2
votes
1answer
131 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
15 views

Select features intersecting a linestring in QGIS

I wrote a python plugin that grabs all (vector, linestring) features between two points on the map. At the moment, I select all features intersecting the rectangle around these two points, and then ...
0
votes
1answer
32 views

pyQGis scale based visibility problem

Im loading some layers from postgis using pyqgis in my standalone qgis app. For each layer i also load a style using: lyr.loadNamedStyle("style.qml") I've setup 2 versions of styles in qgis ...
3
votes
2answers
209 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
1answer
746 views

Calculating distance between latitude and longitude points using python

I have a database of 2000 points, which is in CSV format containing latitude and longitude. I want to find the distance between all these points, and then show these points in a map by using pyQGIS; I ...
2
votes
1answer
41 views

PyQGIS: subtracting two values and append ID to list

I would like to subtract two values retrieved from qgs feature iterator objects and append the value of the feature id to a list depending on a condition. I have two layers: roadsLayer pathsLayer ...
2
votes
1answer
65 views

How to access a specific feature?

Is it possible to go to a specified row number (or perhaps the next/previous) row using PyQGIS? This code gets the value of the first attribute in the first row of the table features = ...
2
votes
1answer
177 views

How to load a *.qgs file in a C++ QGIS standalone app?

I'm using QGIS-2.4.0 API to develop a standalone app by C++. I saved a test.qgs file in QGIS Desktop software, in the project, there was one layer and it was visible. Then I loaded the test.qgs ...
2
votes
2answers
109 views

How to use `layer.getFeatures()` in a standalone script?

I am following the QGIS Cookbook and this post where it concerns reading attributes from layers. I would like to exploit this method and implement it into a standalone script. Essentially, I want to ...
1
vote
1answer
36 views

How to remove a layer and its legend in a standalone pyqgis application?

In continuity in my question "How to add a legend to a canvas in a standalone PyQGIS application?" > In every addition of a new layer in my standalone application, the legend lengthens and becomes ...
1
vote
0answers
21 views

PyQGIS - Syntax for importing WKT file

I couldn't find any proper example of how to import a .csv with WKT coordinates (Polygon) in PyQGIS. Here are more details on my .csv. I am working with polygons. The delimiter is a semi colum, and ...
3
votes
2answers
790 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
363 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 ...
2
votes
1answer
470 views

Help with scripts for processing raster files with the raster calculator in QGIS

I am trying to process some raster files using python scripts in Qgis 2.20, and I have been having trouble finding any documentation on using raster calculator in scripts being run in the processing ...
2
votes
2answers
828 views

How to read the attribute values using PyQGIS?

What is the way to get the information contained in the attribute table, say in column 2, row 2 using pyQgis?
3
votes
1answer
144 views

Programmatically grouping multiple layers into separate groups using QGIS?

I'm trying to group a large number of layers together based on a common portion of name string. They are a mix of polygons and points. I would like to create individual groups by using part of the ...
0
votes
0answers
18 views

Multi Label with Multi Placement

is there any way to add multiple label at different placement in qgis. Suppose I have a vector layer for line geometry and my attribute are name and route number. Now i want to add the route number to ...
2
votes
1answer
43 views

use gdal python bindings from the QGIS folder in a custom script

I have QGIS installed (on Windows) and can import this line from the QGIS Python console: from osgeo import gdal When I try the import in a python file it doesn't work Traceback (most recent call ...
3
votes
1answer
146 views

How to prevent users from removing QGIS layers?

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 ...
3
votes
2answers
120 views

How to add a legend to a canvas in a standalone PyQGIS application?

I am trying to develop a standalone PyQGIS application. The map display does not pose any problems, but I do not know how to add a legend to the canvas.
1
vote
0answers
55 views

Buffer Csv gets repeated when more than one feature is selected in mapcanvas in PYQGIS

I have a function which will allow the user to select a feature or more features in map canvas and performs buffer for the selected feature(s) and writes the output to a csv file. I dont have any ...
2
votes
1answer
151 views

ImportError: No module named processing

this question may have been discussed before but i was not able to find any answer. I am developing a stand alone python script that will invoke methods from processing module. I am seeing error ...
0
votes
1answer
44 views

How to access shapefile m-values with pyqgis?

Does anyone know how to access (read/write) m-values of a line-shapefile using pyqgis? I know how to do it with arcpy cursors ...
1
vote
1answer
48 views

How can I get features that satisfy a QgsExpression using PyQGIS?

I have two fields say "State" and "name" which would be get from the two comboboxes. After which, based on the current text in the combo box, I want to make QgsExpression and feature that satisfies ...
3
votes
1answer
1k 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) ...
0
votes
0answers
28 views

Is PyQt4 'drag and drop' functionality available in Qgis Plugins?

In Qgis 2.8, is it possible to use the PyQt4 drag and drop classes (dragEnterEvent, dropEvent) to interact with items from a qtreeview, in a Python Plugin? Is it possible to hook into the ...
1
vote
1answer
36 views

How to implement Add feature action from PyQGIS

I'm trying to implement / reuse Add Feature functionality in my python plugin. there a class/function that handles geometry creation on canvas based on layer geometry definition? I'm checking API but ...
1
vote
1answer
31 views

Using 3rd party libraries on QGIS (Windows)

How can I use 3rd party libraries on QGIS plugins on Windows? I've developed a plugin that uses rasterio and numpy for a customer, but he's having problems installing rasterio and numpy. Actually ...
0
votes
2answers
49 views

Extract Elevation of Points from DEM using Python QGIS or GRASS

I am utterly new to GIS, so please bear with me if I am providing incomplete information here. I have a DEM file (.dt2). What I am looking to do is as follows: take a series of points specified as ...
2
votes
1answer
91 views

Select by location in Python

I have a polygon layer and a point layer (with coordinates for each point). The polygon layer got created using the MMQGIS PlugIn (Hexagonal Polygons). I want to select all the points inside each ...