Tagged Questions
4
votes
1answer
225 views
QGis Zonal Statistics Plugin NoData included in Calculations
I have been trying to use the QGIS zonal statistics plugin. My raster has a nodata value of -99999 and all other values are positive. After computing the mean zonal statistics there are a number of ...
0
votes
0answers
22 views
Skeleton plugin from QGIS Plugin Builder causing QGIS project to not save [on hold]
Originally I thought my problem was this:
I just got my first simple python plugin for QGIS 2 to start working the way I want it to. It started with the basic plugin builder nub, and I've extended it ...
1
vote
0answers
25 views
How can I use pyqgis to automate a series of field calculations?
I've got a shapefile with about 30 fields that I'll need to update from time to time by importing a CSV with new data, joining it to the shapefile, and using the field calculator to carry the new ...
1
vote
1answer
11 views
reproject vector layer with pyqgis with new CRS does not worl
In QGIS I am running a script in th python toolbar to export all visible vector layers to a GEOJSON with this snippet:
canvas = qgis.utils.iface.mapCanvas()
allLayers = canvas.layers()
for i in ...
2
votes
1answer
424 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
79 views
Load and display a layer using PYQGIS
I'm having a go at using pyqgis from within the QGIS python console to load a layer from SQL Server and display it. I feel like I'm part way there but I'm having a real issue getting the layer to ...
0
votes
0answers
46 views
Issue blocking QGIS feature form dialog with Python
I'm not sure where I'm going wrong with this python logic for a custom form in QGIS 2.0.1. There are a few things required by the validation function: that index of combo boxes aren't 0 (first index ...
1
vote
2answers
138 views
How to handle adding a PostGIS layer in pyQgis without saving password?
I'm writing python plugin and trying to find the right way to add PostGIS layer on the map without storing user password.
After adding layer on the map, I strip out the password from uri like this:
...
0
votes
1answer
40 views
How to copy attribute values of fields in selected features of one layer to another Qgis programmatically?
I am trying to get the values of attributes of the selected features of a layer field by field and copy to another layer that I created in qgis with pyqgis.
Is here a example for this. Every example ...
0
votes
0answers
31 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 ...
0
votes
1answer
66 views
QGis: scripting the map rendering (multiple similar maps from one shapefile)
I would like to ask for advice on creating a Python script that will provide the opportunity to render a plenty of similar maps (with the same extent, projection, layout, color scheme and composition, ...
0
votes
0answers
31 views
How to add the attributes of selected features to my new layer in pyqgis
I am trying to create a layer from the selected points coordinates. I am drawing a circle to the coordinate of selected points. I also need to add initial attributes of my selected features to my new ...
0
votes
4answers
48 views
Why QgsMapCanvas only appear after lost focus?
I created the simple frame .UI file, compiled with pyuic4, and tried the ShapeViewer.py to load the shapefile "world_borders.shp". However, the map doesn't display at the first time. I have to click ...
2
votes
2answers
91 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 ...
0
votes
1answer
120 views
How to perform Graduated Width Markers on Grad. Thickness Lines in QGIS with pyQGIS?
I am using QGIS + pyQGIS + Python. Layer geometry is line. Each line has a magnitude and a direction (from 1st node to 2nd node).
What exactly I want to perform is "graduated width marker symbology ...
3
votes
1answer
387 views
Creating Selection MapTool in PyQgis Custom Application
I'm developing a custom GIS application using PyQgis API.
How can I let the user select features on the map using Maptools? I would like to replicate the select feature there in Qgis to make the ...
1
vote
1answer
57 views
Python.dll could not be loaded with PyScripter
I'm trying to configure PyScripter with QGIS. I've installed it using OSGeo4W and I'm following instructions to setup a pyscripter.bat file by copying content of qgis.bat file. I have the following ...
0
votes
1answer
32 views
Retrieve path of running plugin in QGIS
In my plugin's directory I've got some XML settings files that I'd like to parse at a particular point during execution of the plugin. Is there a way to get the absolute path where the plugin's .pyc ...
1
vote
1answer
37 views
QGIS Map tools and Map canvas--QString errors
I'm trying to learn more about using QGIS Map Canvas widgets and creating custom map tools, so the information from the PyQGIS cookbook is very helpful. After trying to experiment with mywnd.py from ...
1
vote
1answer
104 views
How to save after using fet.setFeatureId in pyQGIS?
By using the following code, I want to change the id of the line when saving the line. But the setFeatureId command, gives a false when doing the commitChanges(). Any idea how to change the id?
vl = ...
0
votes
0answers
15 views
Add a raster specifying the projection in pyqgis
I would like add an raster but I want to specify the projection.
If I do :
qgis.utils.iface.addRasterLayer(url,layerName)
QGIS ask me to specify the projection. I want to this with python.
How I ...
2
votes
1answer
386 views
Joining table to shapefile with pyQGIS
Joining shapefiles is a relatively straightforward proess in QGIS using 'add vector join' in the layer properties menu. I can add a csv file as a vector layer, as well as a shapefile, and join the two ...
2
votes
2answers
942 views
How can I specify the CRS of a raster layer in pyqgis?
I manipulating netcdf raster data from the QGIS python console.
The metadata of my netcdf file does not provide the Reference system. However I know it is 'EPSG:4326'
I am writing a python script to ...
0
votes
0answers
42 views
using postgis function in pyqgis
I'd use Postgis function in Pyqgis script.
This code:
qsql="(select gid, id, St_Buffer(the_geom,200) as geom from archi)"
uri = QgsDataSourceURI()
uri.setConnection("ip", "port", "x", "x", "x")
...
5
votes
2answers
1k views
How do I use QGIS python console to iterate through simple layer queries and png outputs?
I'm really new to QGIS coding and I'm having a hard time finding (especially) the api classes/functions to carry out actions of the Query Builder window.
I'm basically trying to do this:
Iterate ...
1
vote
1answer
154 views
Is there any python function to rotate map layers?
Is there any python function allowing a user to rotate map layers in the map canvas. If so, could you please point this out for me?
I want to rotate a map layer, using a factor of rotation in ...
0
votes
0answers
39 views
How to get the signal when the color changes in pyQGIS?
I would like to have the signal when the color of a vector layer is changed by the user.
In the doc, there is a signal that seems to fit ...
0
votes
0answers
30 views
How to add field to postgres layer with PyQgis?
I'm fetching a posgtres layer with PyQgis and then I'm trying to add field with this:
lyr.startEditing()
lyr.addAttribute(QgsField("class", QVariant.Int))
But It is not adding the field and also ...
1
vote
0answers
47 views
Install PyQGIS in virtualenv
Is it possible to install PyQGIS in virtual environment? I want to use rendering capabilities in my own application which runs using virtualenv.
4
votes
0answers
65 views
How can I modify layer order with the QGIS python API
Typically, after a new_layer = addRasterLayer(...) that inserts new_layer before the active layer, I'd like to move it to the top of the table of contents. How to do it?
I use an existing QGIS ...
0
votes
0answers
36 views
How to get the color of a vector layer in pyQGIS?
I have see this topic (How to change the color of a vector layer in pyQGIS?) but I'm looking for get the color not to change.
How I can resolve my problem ?
Thanks
0
votes
0answers
56 views
How to programmatically set a rule-based renderer in QGIS?
These days im in a process of developing a plugin , which highlights/change color of set of features in a vector layer depending on some calculation.
i found nice article about QGIS – Rule based ...
2
votes
2answers
259 views
How to get field names in pyqgis 2.0
I am trying to change an plugin from QGIS 1.8 to 2.0.
In the 1.8 version I create a table of the field names like this:
layer = vlayer
provider = layer.dataProvider()
feat = QGSFeatrue()
allAttrs = ...
1
vote
0answers
57 views
How can i add a north arrow in QgsComposition?
I'm trying to add an svg image of north arrow in QgsComposition using this code:
mapRenderer = iface.mapCanvas().mapRenderer()
theComposition = QgsComposition(mapRenderer)
...
2
votes
0answers
159 views
Writing Stand Alone PyQGIS Script - QGIS 2.0
I have spent quite a bit of time looking for a clear answer this topic and have still been unable to really accomplish my goal of accessing PyQGIS in a stand alone script.
Parts of answers have been ...
3
votes
1answer
189 views
Rendering and Labeling Shapefile with PyQGIS
I've been running into a few problems working with the QGIS API for python. I've gotten more comfortable working in the python console in QGIS but I run into problems when I try to run the code ...
4
votes
2answers
154 views
Using Python and open source modules, how can I perform Raster Calculator functions?
I would like to perform mathematical functions similar to those you would use Raster Calculator for in ArcMap, however I'd like to do it in Python without using the Arcpy module. I have the osgeo ...
0
votes
0answers
47 views
Missing pyexpat on QGIS 2.0.1: pyuic4 fails
I have encountered a problem when trying to develop a custom plugin for QGIS 2.0.1 (Python 2.7.5 with two additional Python installations on the same machine). When I try to compile the UI file ...
1
vote
2answers
147 views
How to add non spatial sqlite table to map using python in qgis?
Is it possible to load pure sqlite 2.0 (without spatial extension) table into qgis using python? I would like to get the same result as in the case of using Add Vector Layer -> All files.
I have ...
2
votes
2answers
81 views
How can I close the identify result dialog programmatically?
I am trying to close the identify result dialog which appeared when I select to identify a feature from the active layer. Does someone know how can I do it?
1
vote
2answers
186 views
Programmatically load composer from template and generate atlas using pyQgis
I Am trying to build a plugin to load a print composer from file, generate an atlas and export to image. So far I have been successful in loading the template and exporting it to image.
I have been ...
4
votes
2answers
491 views
How to use map composer in a stand-alone script?
I'm trying to follow the map rendering section from the pyqgis cookbook, but I'd like to test this as a standalone application. I can do the first part, using simple rendering, but I'm a bit stuck ...
1
vote
1answer
105 views
How to begin with tool development for GRASS gis or QGIS GRASS
I wanted to begin with customized tool development in Grass GIS or QGIS grass. How should i begin in to develop the tool. I search a lot in google search engine for begin with tool development in ...
0
votes
2answers
188 views
extract edge of a line of a vector layer in a new point layer [closed]
I'm using python to build a plug-in in Qgis.
I need to extract the edges of each line feature of a vector layer to create a new point layer of all edges.
Someone can help me?
My data input is a vector ...
3
votes
1answer
185 views
How to apply a color gradient to a shapefile from QGIS console?
Anyone knows how to do a color gradient from the console to a shape file in Qgis (orin Python)? Like the image below.
0
votes
1answer
186 views
How to set PYTHONPATH in OS X to use PyQGIS?
I am trying to use PyQGIS in custom applications.
I am on Mac OS X 10.9 with QGIS 2.0.1-Dufour.
I know I have to set the the PYTHONPATH environment variable.
This is the path to QGIS on OS X: ...
5
votes
1answer
482 views
Speed of editing attributes in QGIS from a Python plugin
I'm trying to edit the value of an attribute for each feature in a layer using a QGIS Python plugin. I've found that doing this outside of editing mode is much slower than while editing (even ...
2
votes
2answers
661 views
PyQgis overwrite shape file and adding layer to Qgis
I am creating a shapefile in python by:
driver = ogr.GetDriverByName('ESRI Shapefile')
datasource = driver.CreateDataSource('c:/temp/toke2.shp')
layer = ...
1
vote
1answer
71 views
Irrational feature ID behavior in a PyQgis script
I've written a script to determine the coordinates of a point shapefile and insert them into its attribute table.
It works perfectly when the ID sequence of the indiviual features begins with 0, yet ...
0
votes
0answers
103 views
Calculating area with python qgis
I am a little stumped with determining the area of polygons in the python console. I want the output to be in meters^2, so using:
qgis.utils.iface.mapCanvas().setMapUnits(0)
...