Python bindings for QGIS.

learn more… | top users | synonyms (1)

2
votes
1answer
112 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) uri.setDataSource(...
2
votes
1answer
104 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
199 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
187 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
68 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
64 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
43 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
167 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
173 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
52 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 qgis....
2
votes
1answer
243 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
209 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
130 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
83 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
255 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
40 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
55 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. http://qgis.local/cgi-bin/qgis_mapserv.fcgi?MAP=/home/mario/wms.qgs&...
1
vote
1answer
80 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
73 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
158 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
178 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
92 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
45 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
75 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
109 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
190 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
122 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
60 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
36 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
58 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
242 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
42 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
94 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
40 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
267 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
36 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
198 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
49 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
506 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
309 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
60 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
125 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
45 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 ...
1
vote
0answers
108 views

How to view the features of a point with a click in QGIS

I am developing a plug-in for QGIS. I am creating a form of personalized editing using QtCreator. The form is in the following image I read a csv file and when i click in a button OK I get a layer ...
5
votes
1answer
108 views

How to load layers from postgres using SELECT statement?

I am trying to load a postgres table (columns extracted using a select statement) from the python console in QGis: The following works fine and the layer loads as expected: uri = QgsDataSourceURI() ...
1
vote
1answer
95 views

How to update the attribute table in layer from dictionaries using python

I have dictionary with the values: dict = {0L: {'val1': 60, 'val2': 199, 'val3': 7.719},1L: {'val1': 60, 'val2': 199, 'val3': 7.719}} I want to update these values in the attribute table of a layer....
1
vote
2answers
35 views

Putting result of selection of plots in frame of QGIS?

I have made a plugin for QGIS in pyQt. Then I can make a query from a PostGIS database and I get the plot or bunch or plots results of that query in a layer. This layer is overlapped on the top of a ...
2
votes
1answer
83 views

pyqgis traversing subgroups and group layers

I am trying to find the name of subgroups using pyqgis. I have been trying to use Playing with subgroups I am however unable to traverse and get the names of the subgroup. I have tried the code on ...
1
vote
0answers
110 views

WKID issue when adding raster layer from ArcGIS “mapserver” to QGIS via REST

QGIS docs here describe how to do this. I am trying to add a layer from this MapServer: gps.digimap.gg/arcgis/rest/services/JerseyBaseMap/MapServer When I try the following command from the Python ...
3
votes
2answers
161 views

pyqgis add a picture

I am looking for a way to add a picture to my map using pyqgis. Are there any examples of how to do this. I know it can be done using the classQgsComposerPicture. I am not much of a programmer so I ...