0
votes
1answer
36 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
25 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
0answers
27 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
1answer
65 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
45 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
1answer
56 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
32 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 ...
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 ...
0
votes
0answers
41 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") ...
1
vote
1answer
76 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
4answers
45 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 ...
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
29 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
43 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
64 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
34 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
53 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 ...
1
vote
0answers
55 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
156 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
169 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
149 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 ...
2
votes
2answers
77 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?
2
votes
2answers
89 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 ...
3
votes
1answer
183 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
163 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: ...
1
vote
1answer
70 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
101 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) ...
1
vote
2answers
172 views

How to access user credentials in database connection?

I am trying to automate a couple of things when a QGIS plugin is activated: If Layer A is not in the TOC, add it. This requests username and password to access a PostGIS table using the inbuilt ...
2
votes
1answer
110 views

Which data providers support loading attribute tables without geometry?

I have a table in Memory from a cx_Oracle query (a list of rows, and a list of field names and their types) in my python plugin and I want to load it as a geometry-less layer (Attribute table) in ...
0
votes
0answers
72 views

Unable to render layers in MapCanvas using PyQGIS/PyQt4

I am trying to get some layers into a MapCanvas and style them. I am following the PyQgis Cookbook info here but my code is just not working. I've been spinning my wheels on this for over a week now ...
1
vote
1answer
164 views

How to label vector features programmatically?

I am using python for QGIS 2.0.1 and I have a vector layer of points representing the positions of state labels. I want to display the 'state abbreviation' attribute on the corresponding point for ...
1
vote
2answers
176 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 ...
10
votes
1answer
257 views

PyQGIS file lock release

I was wondering what triggers the release of file locks in pyQGIS? I am trying to delete a few data sources (used temporarily) by calling QgsVectorFileWriter.deleteShapeFile, but I have to quit QGIS ...
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 ...
2
votes
2answers
249 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
1answer
74 views

Different output from running algorithm in toolbox and from script

I am unable to get the same results when running the qgis:reproject tool from QGIS processing toolbox (QGIS version 2.0.1) as when running it from a Python script (console). In this example I am ...
2
votes
2answers
109 views

No prj file output from qgis:reproject

I'm trying to reproject a vector layer using the 'qgis:reproject' algorithm in the processing/sextante module of QGIS, from Python. This kind of works, but the .prj and .qpj files created after ...
2
votes
1answer
158 views

Select by SQL in QGIS Python

In the GUI there is the Query Builder, but that does not seem to be easily available in Python. The processing (SEXTANTE) module has the qgis:selectbyattribute algorithm, but that only supports ...
5
votes
0answers
48 views

Using QGIS plugins from Python [duplicate]

Is there a simple way to automate calls to QGIS plugins from a QGIS Python script? Either from console or a plugin? I am ideally looking for a way to specify input/output parameters and bypass GUI. ...
2
votes
2answers
433 views

how to for loop a folder to batch clip rasters by polygon using python and QGIS

I am using python and QGIS 2.0. I am trying to clip rasters in a folder by one polygon feature. It's the first time for me using (let's say) "PyQGIS", I was used to arcpy before. Anyway, I don't get ...
0
votes
0answers
20 views

How to SUM the fields selected in aqlistwidget using PyQgis?

I'm beginner user of PyQGIS and I'm trying to write my first plugin(API 2.0). In my ui file I created a qcombobox to select a layer, and a qlistwidget to select one or more than one fields (x,y,..). ...
1
vote
0answers
124 views

Unable to use pyQGiS in a custom application - import arcgis.core error

I'm using windows 7 and/or 8 64 bit with QGiS 2.01. I'm wanting to us the pyQGiS tools in a custom python application outside of the QGiS environment (i.e by running a python executable located in ...
2
votes
1answer
171 views

How to create a QGIS action which copies features between layers?

i tried (i never tried before...) to write a simple python code like action in QGIS on my "XXX" vector layer that: open a layer "YYY" copy the selected feature on my "XXX"layer paste the selected ...
3
votes
1answer
217 views

Using the Processing Framework in QGIS 2.0

I am writing a plugin for QGIS 2.0, and I want to use the processing framework to call some functions. When I open the pyhton console inside QGIS, I am able to call it like this: >> import ...
6
votes
2answers
505 views

Split a feature when intersecting with a feature of another layer using PyQGIS/Python?

I have a buffer layer (green polygon) which I want to split to two polygons whenever it crosses a barrier (blue line). I have been trying to use "splitGeometry" method, but I just can't get it to ...
3
votes
1answer
161 views

How to programmatically detect a canvas refresh or pan/zoom in QGIS

For my python plugin I would like to remove a VertexMarker when the user pans/zooms there map. Which is the best way to detect a canvas refresh or pan/zoom carried out by the user? Can you suggest ...
1
vote
0answers
122 views

How to change the color of a selected feature with pyQGIS?

is it possible to change the color of a selected feature in qgis 1.8? To highlight a feature I use: vlayer.setSelectedFeatures(selectedList) box = vlayer.boundingBoxOfSelected() ...
1
vote
0answers
70 views

How to join attributes by location with command line

I would like to joint the attributes of 2 shapefiles by location but with a command line (linux). This feature is easy in QGIS but it is VERY slow. Is there a way of doing this with ogr or pyqgis ? ...