Python bindings for QGIS.

learn more… | top users | synonyms (1)

3
votes
1answer
69 views

Setting QgsExpression for QgsPalLayerSettings in QGIS

How do you apply a QgsExpression to a Label ? I can do it in QGIS with this simple expression concat('N:' ,round(Value,0),'\n','Yield:' ,round(Value 2,0)) N: 65 Yield: 40 How do I do it in ...
2
votes
2answers
191 views

Set predefined scales in PyQGIS for standalone application

I am trying to figure out how to set the zoom scales to match those meant for OpenStreetMaps and Google Maps, etc., as I am using OSM for a basemap. I've looked all over the internet and can't seem to ...
2
votes
0answers
58 views

Getting number of rendered features per range with PyQGIS?

I would like to know how many features are rendered in my QgsGraduatedSymbolRendererV2 per range. I need to know also the exact range (lower and upper value). I know how to get each range : ...
2
votes
1answer
54 views

QImage Not Defined [closed]

I am trying to get a set of map images with a Python script in QGIS. I load the background raster and my csv vector file and then I try to get the image. When I start the example from the PyQGIS ...
2
votes
3answers
62 views

Keeping my own additional Python layer information for potential further usage in QGIS

I wrote a plugin that selectively loads simulation data to QGIS. That works fine, but the overhead to convert the data from my own format to QGIS takes a long time, as I have to generate an index and ...
7
votes
1answer
146 views

Filling fields with conditional clauses

I have four fields in my shapefile. I would like to fill only one of them (cell of attribute table) and automatically after to write one cell the others one will be filled by conditional clause. I ...
2
votes
1answer
68 views

OpenStreetMap heavily pixellated when loaded in QGIS and standalone application

I am loading an OSM street map into an application I am building. I load it as a raster layer via an XML document with the OSM GDAL data. My problem is that the map appears heavily mangled and ...
1
vote
2answers
75 views

Adding a csv layer in PyQGIS

I am trying to load a series of csv files as vectors in PyQGIS. I run this code to try to get the first one: uri='file://D:/Saved Stuff/gulags/1.40.csv?delimiter=;&yField=y&xField=x' layer = ...
1
vote
0answers
35 views

Struggling to install QGIS from source in RHEL 6.4 [closed]

I have installed QGIS from source in Ubuntu using the this link. In ubuntu I compiled qgis from source without any problem. but now I moved to RHEL 6.4, not able to run QGIS from source. The steps I ...
1
vote
0answers
22 views

Error when zooming to layer in PyQGIS application. On-the-fly transformation the issue?

I am trying to set the extent of my window to a layer on my canvas. This has worked smoothly until I started using Web Mercator maps instead of WGS84 maps. My features are getting their geolocation ...
2
votes
1answer
180 views

How do you loop through raster layers in a folder with PyQGIS?

I'm looking to apply a mask to a number of rasters in PyQGIS. (updated but still not working) import processing rstr = "/Users/rasterfilepath/" shp = "/Users/shapefile.shp" outputDir = ...
2
votes
1answer
132 views

Set label transparency in PyQGIS

I have been trying to figure out how to set the transparency of my labels and label buffers in PyQGIS for an application I am building. I am using the "setCustomProperty" class from the QGIS API. I ...
2
votes
1answer
52 views

PyQGIS - Style Features individually based on attribute value - custom renderer as option?

I am trying to colorize all features in all layers in my QGIS 2.8.2-Document based on a color-value, that is being determined for every Feature individually. I do have a QtGui.QColor instance for ...
3
votes
1answer
73 views

QFileDialog remains open after selection made

I have created a QGIS plugin to import a tab separated value file, using: filename = QFileDialog.getOpenFileName(self.dlg, "Select file to import ", path, '*.*') ...
1
vote
2answers
83 views

PyQGIS method to add multiple GDB files?

I can use the following to add multiple shapefiles to QGIS: import os, glob layers=[] shape_path = "C:\Users\Me\Desktop\Test\Shapefiles\\" for shape in glob.glob(shape_path + "*.shp"): layer = ...
0
votes
1answer
34 views

How can i display length according line angle?

I want to display length according to part 1 Image. but now its making like part 2. I am using below code. import shapefile from PIL import Image,ImageDraw, ImageFont from qgis.utils import iface ...
4
votes
2answers
313 views

How to activate a layer by its name in PyQGIS?

I'm writing a script that requires the attributes of different layers to work, and I would like to know how to call a layer that is not the currently active one and get its features. For example, I ...
3
votes
1answer
49 views

Enable and disable styling rules

I have a vector layer in qgis. I have added a bunch of rule for this layer. This is the QDockWidget for layer in QGIS main window So each of interstate, divided, secondary is different rule added ...
2
votes
0answers
41 views

Finding which polygon feature is most in using PyQGIS?

I have a vector layer of land parcels and another layer of polygons separating them into territories. I am trying to identify which territory each parcel is in within a python plugin. My plan is to ...
2
votes
1answer
186 views

How to save postgres table to kml without losing attributes using python

I am saving the postgres table loaded in QGIS to kml. qgis.core.QgsVectorFileWriter.writeAsVectorFormat(aLayer, myFile, "ogr", projDest, "KML") But the output file does not have the attributes. So ...
1
vote
1answer
130 views

Load the postgis layer/table to qgis canvas using python

I want to load the postgis layer to qgis canvas. I am using the following code but it is not loading the layer in canvas. sql = "(SELECT * FROM table WHERE id = 20)" uri = QgsDataSourceURI() ...
1
vote
0answers
75 views

Getting current geoposition coordinates in Python? [closed]

I want to get my current geographical address so that i can extract data from my database using address matching. I am using django. I know how to get coordinates in html 5 and address from ...
2
votes
1answer
100 views

Why does pyQGIS QgsVectorLayer().isValid() return FALSE with Oracle views?

This works perfectly fine with an Oracle TABLE but not with a VIEW. Why? uri = QgsDataSourceURI() uri.setConnection(host, port, db, username, pw) uri.setWkbType(QGis.WKBPolygon) ...
2
votes
1answer
98 views

Fully symbolize a vector field marker in PyQGIS

I'm designing a symbol for an external application that needs to be a vector field marker combined with a simple point marker, displaying a line at a certain angle around the center point. In PyQGIS, ...
1
vote
1answer
168 views

Adding label to QGIS map composer through Python script?

I need help in adding a label to QGIS map composer through python script. I could add a label but it is incomplete. The label is like this: 27-02-15 11-25. It only shows the first part: 27-02-15. I ...
2
votes
0answers
171 views

PyQGIS with Pycharm CE 4.5

I'm able to run PyQGIS on my Mac (OSX 10.10.3) through the Python (2.7) console and through execution of Python files through my terminal. In order to do so, I added the following to my bash_profile: ...
4
votes
1answer
65 views

Adding a PyQGIS Plugin to the Database Menu

I am developing a plugin which I would like to add to the Database menu instead of the default Plugins menu. According to the PyQGIS Developer Cookbook all I have to do is add category=Database to ...
1
vote
2answers
59 views

Getting number of objects in attribute table using PyQGIS?

I have a layer and I would like to access the number of rows the attribute table has from my code. Is there a way to do that without doing it like this: Index = 0 for Feat in Layer.getFeatures(): ...
1
vote
0answers
42 views

QGIS python file error for fetching script info

Currently i am working on automated map generation using Python coding in QGIS. i saved my all code but wile fetching the file into Script runner plug in i am getting error that you moved or deleted ...
1
vote
0answers
153 views

PyQGIS export return blank .tif

I'm new to pyqgis and trying to bring up from the previous post with a little progress from the last (implemented debugging tool pdb) but now trying to export into a .tif file so that I can check on ...
0
votes
0answers
139 views

Using python to change vector style

I am trying to change a qml style using pyqgis. The style is rule based with 12 rules each with different symbology. All the symbols are two layers (one is 3 layers). In two of the rules, I would like ...
0
votes
0answers
50 views

PyQGIS render vector layer into .tif?

How can I render a vector layer into .tif file? I tried with below codes without luck. PS: I am doing this on ubuntu server and running it via PyQGIS. Python scripts #!/usr/bin/python from ...
2
votes
1answer
223 views

Measure distance between vertices of polylines in QGIS for Desktop

I have this dataset of coordinates of electric lines in the form of vector polylines as shown in the image below, and I need to measure the distance between the first and last vertex of each line and ...
3
votes
2answers
190 views

Measure distances between specific features in QGIS for Desktop

I'm completely new using PyQGIS and developing plugins. Currently I have a layer with the X and Y coordinates of electric distribution poles, where each pole is a feature. What I need to do is ...
2
votes
1answer
121 views

QGIS:joinattributesbylocation gives empty shapefiles and QGIS:joinbylocation does not give summary of all fields

I am trying to make a spatial join to calculate the mean value of many variables (100+ columns) of census tracts by city. In order to do that, I would, in QGIS Desktop, run a spatial join (join ...
2
votes
0answers
75 views

Some layers won't load when running application out of QGIS. “Item has already been added to this scene”?

I'm developing a basic application out of QGIS and am having trouble getting my code to generate all the layers I have set. Currently it only generates two of the four layers: "self.basemap_layer", ...
2
votes
1answer
224 views

Why does iface.activeLayer() not work in a PyQGis standalone app?

it is my second day on PyQGIS. Not sure why layer doesn't return anything. Anyone can help me on this? Code: #!/usr/bin/python from qgis.core import * from qgis.utils import * from PyQt4.QtCore ...
1
vote
0answers
37 views

Layer failed to load?

I have this piece of codes running via pyqgis and trying to get raster layer from "elevp.csv". However, when executing this scripts it error kept returning "Layer failed to load". Anyone know how to ...
1
vote
0answers
49 views

QGIS Composer labels with expressions - Custom functions

I'm trying use GetPrint request with qgis server and I find feature that you can assign value of function to label (with id) ex. ...
1
vote
1answer
75 views

How to edit shapefile name written to attribute table in QGIS?

I have adapted some QGIS pythonscript code from a previous question to assign the filename of a shapefile to that shapefiles attribute table as a prelude to joining multiple shapefiles together (the ...
1
vote
1answer
66 views

PyQGIS filter using date column

In QGIS python console, I can run the following to extract the week number from date column. How can I use the same in qgsExpression as a where clause? Any other option is welcome as long as it uses ...
2
votes
0answers
137 views

QGIS-Python Need to check if layer is in current extent and make it active

I'm putting together a plugin for QGIS. The user inputs a county and a coordinate pair. The plugin then adds in the county data and zooms to the given coordinates. The problem is that there are ...
0
votes
0answers
170 views

get latitude and longitude of each grid point in a grid with squared cells based on a given shapefile

I would like to draw a grid whose cells are all squared on a given shape file. The shape file has the information of U.S. map at zip code or county level. I need to create the squared grid (with a ...
4
votes
1answer
89 views

Is there a way to locate plugins in the QGIS gui programatically from pyqgis?

I've let my love of shiny new QGIS plugins get the better of me, and I'm finding it difficult to remember which menu / submenu / panel that a given plugin is in. I'm using well over 100 now, and going ...
1
vote
0answers
39 views

Network analysis library - example from PYQGIS developer cookbook does not work

I am using QGIS 2.6. I'd like to be able to calculate the driving distance between any two geocoded locations (can't use the shortest path roads plugin because it appears to be interactive and I need ...
1
vote
1answer
72 views

How to select a feature with the mouse click programmaticaly

I am working in c++/QT 4.8.5 and the api c++ qgis 2.8.2 In my application i had top select layer with the mouse click button to get attribute value and show them in a popup windows I see in the api ...
1
vote
1answer
99 views

How to get features by attribute using PyQgis?

How can I get a feature's geometry from selection by attribute. For instance from a point layer I want to get the geometry by the field CODICE filter (CODICE = A001). I tried with: layer = ...
2
votes
1answer
171 views

How to get pixel values of indvidual pixels falling under a poygon to shapefile attribute table or CSV?

I want to be able to write pixel values of each pixel falling under a polygon onto a polygon attribute table or a CSV. I have about 1200 polygons and a georefernced GeoTiff file with NDVI values. ...
3
votes
1answer
110 views

QGIS: can't run processing.algrun() in external Python application

I am trying to create an external Python application. I want to run this as a stand alone program in command line. I am trying to not use the QGIS console. A first step is to clip a point shapefile ...
1
vote
0answers
53 views

In QGIS Python console how can I calculate given the distance, bearing and initial point, the final point

In QGIS Python console, how can I calculate the location of a final point, given a distance and bearing from an initial point? In PostGis I see that it is ST_Project, however I would like to do it ...