Python bindings for QGIS.

learn more… | top users | synonyms (1)

1
vote
1answer
67 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
90 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
165 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
104 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
51 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
34 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
43 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
184 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
38 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
79 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
38 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
201 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
34 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
179 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
47 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
439 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
266 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
53 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
85 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
83 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 ...
4
votes
0answers
77 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
75 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 ...
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
74 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
97 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
144 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 ...
1
vote
1answer
143 views

Move feature in front

Is it possible to move feature in front of another? If I have smaller polygon and I draw larger polygon over it, is there a way how to move the smaller one in front? Is it possible in QGIS or better ...
3
votes
1answer
91 views

QgsExpression using complex sql and python subsitution

I have a sql statement i am running in postgres fine and would like to transfer it to a QgsExpression mainly because I have loaded the layer in Qgis. My sql is: select column a,column b from table1 ...
1
vote
1answer
104 views

How to calculate the raster statistics with polygon layer using numpy and scipy in python?

I have used zonal statistics from processing to calculate the raster statastics with polygon layer. processing.runalg('qgis:zonalstatistics', rlayersource, 1, vlayer, None, True, Path) But this is ...
4
votes
1answer
357 views

Showing only some layers in QGIS legend?

My QGIS 2.8.2 standalone app provides several decorating layers (e.g. cartographic grid, background layers, reference points) which should be not changed by the user (neither editing nor hiding), as ...
2
votes
0answers
58 views

How to display selected features in a map to exporte as PDF

I've already managed to select feature by ID in a layer and zoom to it using pyqgis. The canvas considered this changes but the map that I exported as PDF do not consider this changes, any idea to ...
1
vote
1answer
197 views

How to find the intersection length between two polygons using python

I have two polygons and i want to find the intersection line length between these polygons. for geom1,geom2 in itertools.permutations(selection,r=2): intersection ...
2
votes
1answer
291 views

How to create a valid QgsVectorLayer from delimitedtext?

I am having trouble loading csv files into layers using QgsVectorLayer(). I know this looks like a repeat, but I have carefully read Create a script to add delimited text layer in QGIS and ...
1
vote
2answers
173 views

Set color to polygons

I need to color each polygon based on its area and length. I can loop through all polygons, find out their area .geometry().area() and if it is larger than 100 meters squared, than I want it to be ...
1
vote
1answer
182 views

Checking layers with scale based visibility for visibility in QGIS

I am writing a Python method which I want the mouse click event to connect to. The method selects objects from layers that satisfy certain conditions. I want to select from any visible layer, that has ...
2
votes
2answers
71 views

How to load stored composer from project file in standalone QGIS application?

I would like to load a .qgs file and get a composer from it, but I can't figure out how. Is there a way, or do I have to read the xml myself and individually set the appropriate values for the ...
2
votes
1answer
92 views

Align and reshape polygons based on surrounding polylines

I am trying to use a shapefile with polygons and I am trying to align it to a road network, that the polygons align themselves to surrounding streets. Is there a way to automatize alignments between ...
1
vote
2answers
206 views

How to show variable values in message bar in QGIS?

I know that I can write custom text to message bar with the QgsMessageBar.pushMessage() method. But if I understand the documentation right, there's no room for variables added to a string where they ...
1
vote
1answer
57 views

How to register a broadcast on QGIS to start my plugin on start after loading plugins

I want to perform a default task when user opens QGIS but here I am building it as a python plugin so I want a signal or broadcast to call my plugin. I didn't build QGIS from source my plugin should ...
2
votes
0answers
107 views

Multiprocessing in python qgis?

When i try to do mutliprocessing in python Qgis it doesn't work from multiprocessing import Process,Lock import multiprocessing def name1(l,i): print i if __name__=='__main__': lock=Lock() ...
2
votes
1answer
226 views

Remove inner rings from QgsGeometry polygon in QGIS Python

I am a QGIS python user. I want to iterate over the rings of a polygon to remove holes in the polygon, so: I need to iterate over the rings in a QgsGeometry polygon I need to detect the main ring ...
1
vote
1answer
117 views

Python script to copy first row of certain attributes and paste in the newly digitised rows the copied features

Starting from this question, I need a script to be insterted in the processing graphical modeler that can copy some attributes from the first digitised row in all the newly digitised lines of a ...
2
votes
2answers
130 views

Store in a python list the attribute table of a vector in QGIS

I'm stuck with a very simple issue.. I've loaded in QGIS (through the py console) a csv layer (no geometry) made of 4 fields and 3 rows: #load the csv layer = QgsVectorLayer("path/to/the/csv", ...
2
votes
2answers
98 views

How to find the irregular polygons in qgis using python

I have a vector shape file and i want to find the irregular polygons. What are the parameters to be considered to check the iregularity of the polygon features? Calculating the perimeter and extent ...
4
votes
5answers
333 views

Is there any simple integration for counting points in polygon using python qgis?

Is there any simple integration for calculating count of points in polygon using QGIS-Python integration? In other words, are there any pre-defined functions for points in polygon of QGIS using ...
1
vote
1answer
192 views

Can we count the points in polygon using pyqgis code? [duplicate]

Does anyone know how to calculate the point in polygon from the given points and the buffer output using python qgis. I have every thing loading the data and retrieving the output. But now I want to ...
1
vote
0answers
56 views

How to modify the “Network Analysis Library” in QGIS?

I want to modify the network analysis library because th graph builder does something I don't want. When there is an intersection between to lines, it creates a node in it. I want to avoid this ...
2
votes
0answers
178 views

Can we create buffer analysis using python in qgis?

Can we create a buffer of distance 0.004 using python in qgis. I tried this link, but it isn't working for python in qgis 2.10.1-Pisa. The above is the diagram of buffer I am asking. It's located ...
1
vote
1answer
78 views

pyQgis - set Variables on startup

via startup.py it is possible to execute python code when qgis starts. Now I wonder, whether it is possible to set variable values, eg. a string variable which holds a path or a dictionary of values, ...