Python bindings for QGIS.

learn more… | top users | synonyms (1)

0
votes
1answer
30 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
120 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
44 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
38 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
129 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
77 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
60 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
71 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
55 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
90 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
102 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
58 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
50 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
29 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
115 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
73 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
46 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
129 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
118 views

Measure distances between specific features in QGIS for Desktop

I'm completely new using PyQGIS and developing plugins, and I would appreciate some orientation. Currently I have a layer with the X and Y coordinates of electric distribution poles, where each pole ...
2
votes
1answer
86 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
44 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
124 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
29 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
40 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
58 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
60 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 ...
1
vote
0answers
92 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
119 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
76 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
26 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
56 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
66 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
128 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. ...
2
votes
1answer
73 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
45 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 ...
0
votes
0answers
33 views

Port QGIS window and developed features to external application

I have developed a series of features in QGIS that will represent data in near-realtime. These features will respond to changes made in a series of external CSVs, which take their data from hardware. ...
1
vote
0answers
29 views

Is it possible to lock the layers using Qgis API Python?

I would need to load and "lock" two layers on the map. Locked means that layers cannot be removed from the layer registry. When I say removed I mean removed by the user using the QGIS interface (the ...
0
votes
1answer
107 views

PyQGIS: how to transform single QgsGeometry object from one CRS to the other?

I have a polyline layer with roads in WGS84 that covers several UTM zones. For every road I need to place a set of points at different distances (in metres). To do so I want to reproject each road to ...
1
vote
0answers
28 views

Clip vector with grid using loop to do fragstats background

I would like to put background border - with negative values - in my squere landscape in order to use in fragstats. I'm trying to do it with pyqgis. Exemple what I would like to do (figure 3). So, I ...
1
vote
1answer
61 views

Updating an Open Attribute Table

A work-in-progress plugin's dialog window contains a rolodex which allows the user to cycle through a timeseries of data; updating the relative memory layers geometries with each new time selection. ...
1
vote
1answer
34 views

pyqgis: displaying 2 different datasets in one instance

I have a need to display 2 completely different sets of spatial data in a single standalone qgis application. This means, 2 separate sets of layers, 2 map canvases, etc. Is this at all possible? ...
2
votes
2answers
132 views

Selecting features within polygon from another layer using R or Python?

For Selecting features within polygon from another layer using QGIS? the solution was to: use the "Vector->Research tools->Select by Location" However, I would like to know how to do the same ...
2
votes
1answer
29 views

Search Shapefile and return Extents

Looking to convert this Arcpy script to pyQGIS. I sure Hope pyGIS has an user input that works outside the command line. # make custom button to search Parcels by Parcel Number # and zoom to selected ...
2
votes
0answers
146 views

Import processing module from QGIS into Python Window of ArcCatalog?

It is possible to import processing module from QGIS and run it in Python Window of ArcCatalog? I tred in qgis import sys output = sys.path and copy output to arcgis console: import sys for x ...
1
vote
1answer
42 views

Editing multiple layers using QGIS?

I'm wondering how to edit multiple layers, maybe standalone. I have 2 shapefiles. 1 line and 1 point What i want is the following: When i select a line, then the line and the point shape has to go ...
0
votes
1answer
320 views

ImportError: No module named qgis.core from PyQGIS?

Trying to load QGIS -- I have a working copy of Python: 2.7.9 -- It looks like QGIS is not finding PyQGIS. I am aware that this is a problem with the PATH but do not see how to fix it. > My ...
5
votes
1answer
232 views

Extent problem in PyQgis

I'm trying to set the extent of a square feature to the canvas, that works in QGIS, but when I print the canvas into a PDF, it always gives me some empty area, below is the screenshot of QGIS canvas ...
1
vote
0answers
48 views

Populate empty attribute table from constantly growing CSV in QGIS

I have a Python script running that will generate a line feature from a point depending on a degree of rotation around that point. I have a non-spatial CSV setup to get fed this rotation data from ...
2
votes
1answer
64 views

Getting list of QGIS field names, not including hidden fields using PyQGIS

Currently, for a python plugin for QGIS 2.8.3, I get the list of fields for a layer using pendingFields as mentioned in this thread: fields = self.layer.pendingFields() I now have a few hidden ...
2
votes
0answers
41 views

PyQGIS reference to QGIS plugin UI in Travis unittest

I want to get unittesting under Travis to work with qgis2web. It works up to a point, but Python access within the plugin to the plugin's own UI seems not to be working. The unittest I am working on ...