0
votes
0answers
11 views

can not delete file after using runalg function

I my plugin I use the runalg function: processing.runalg("qgis:clip",filepath + "/temp2.shp", Layer, filepath + '/' + layerName) vlayer = QgsVectorLayer(filepath + '/' + layerName + '.shp',layerName, ...
0
votes
1answer
22 views

Save as .csv with coordinates in both QGIS 2.2 and PyqGIS

These questions have been asked before, but since they are not answered I will try to pick up the ends here. 1) First, as stated here: QGIS 2.2 saving layer as CSV with GEOMETRY=AS_WKT not working ...
0
votes
1answer
20 views

Run ftools multiparts to singleparts from PYQGIS

Is it possible to run the multiparts to singleparts function from the console with the processing_runalg function? Or is there another way?
0
votes
1answer
32 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
24 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
25 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
0answers
14 views

Multiparts and Multigeometries: checking for multigeometries with PyQGIS?

I have been working with PyQGIS and writing a small script to check whether the layers I have in the MapCanvas have geometries of type "MultiXX" because I want to run the "Multipart to Singleparts" ...
0
votes
1answer
58 views
+100

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
17 views

insertVertex giving false in pyQGIS

I have this code from my plugin which work in Qgis 1.8 and I am trying to make it work in 2.0. I want to insert a coordinate x and y into a polyline after the last entry. points = geom.asPolyline() ...
0
votes
1answer
40 views

Replacement of QVariant and setAttributeMap in PyQGIS

I am updating a plugin for QGIS 1.8 to QGIS 2.x. I have the code below. The setAttributeMap does not exist anymore. I have replaced it with fet.setAttributes and it seems to work. When using ...
0
votes
0answers
20 views

How can I reproject a layer in pyqgis?

I have a problem. I'm currently trying to get the extent of a vector layer in latitude and longitude coordinates in python. The layer is currently in EPSG:3857, so .fullExtent() is not returning what ...
1
vote
1answer
17 views

Alias's in the Attribute Table's Column Preview/Column Filters

We've spent some time setting up alias's in Layers/Properties.../Fields (Fig. 1) for database fields displayed as the column headers in the Attribute Table (Fig. 2). Switching the layout in the ...
0
votes
0answers
44 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 ...
2
votes
0answers
83 views

How to eliminate gaps and overlaps in a layer of SpatiaLite table?

I'm try to snap all polygons in a table to remove gaps and overlaps. I can remove gaps but get new overlaps. I have no idea what doing wrong... sorry, I'm new in SpatiaLite. I tried the following: ...
2
votes
1answer
60 views

How to adjust QGIS attribute table view column width using Python?

I'm programmatically opening the Attribute table via Python through a plugin. All of the columns have a default width, but some of the data that I'm using do not fit. It's not enough to be able to ...
0
votes
0answers
29 views

Problem with QgsVectorFileWriter

I am trying to write a python script that when it is called it will take an .sqlite layer and save it as a GeoJSON layer. This will be used in a leaflet app but for now my problem is with this script. ...
0
votes
1answer
29 views

Displaying QGIS layer after loading with Python

I'm successfully loading several layers with Python, but can only get to see them in the map window if I manually zoom to extent afterwards. Once the last layer is loaded I call zoom to extent in the ...
1
vote
1answer
54 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 ...
2
votes
0answers
33 views

How to open QGIS attribute table in form view using Python?

I've got a plugin where I load some layers. On the last layer loaded I show the attribute table. I would like to select the view different from the table view (see image). How can I do this in Python? ...
0
votes
1answer
31 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
54 views

Can't select layer in the Road Graph plugin QGIS

I'm trying to use the Road Graph plugin in QGIS 2.2.0. I have tried a few line shape files, but it won't let me select the layer (the option is greyed out). I've tried adding a 'SPEED' field and a ...
1
vote
1answer
31 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
2answers
130 views

How to set Eclipse and PyDev for QGIS when ArcGIS is installed?

I have got a lot problems with the configuration of Eclipse with PyDev in order to develop QGIS plugins. The situation is very weird and frustrating. I can import qgis module using Pyscripter without ...
1
vote
2answers
58 views

How to remove/disable a toolbar via python?

How do I remove or disable a toolbar e.g., Raster, programmatically using Python?
1
vote
1answer
52 views

Got Null values when updating attributes with PyQgis

I'm trying to create and update a field and ,for now, just change it's value to 2. Here is my code: layer = qgis.utils.iface.activeLayer() index = layer.fieldNameIndex("P") # if index == -1: # ...
1
vote
1answer
44 views

Failed load delimited layer in QGIS python console

I'm trying to follow the map rendering section from the pyqgis cookbook. I am able render shape file using qgs vector layer, however getting error prompt while loading delimited text file through qgs ...
0
votes
0answers
40 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") ...
0
votes
1answer
78 views

Code works on python console in QGIS but same doesn't work in stand alone script

I'm trying map rendering with stand alone script, so I have small script which works fine in python console provided QGIS, however when I run same code in stand-alone script it executes without error, ...
1
vote
1answer
72 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 ...
1
vote
1answer
75 views

How to call a method by BOTH a button AND a key shortcut

I have been trying to call a method by BOTH a key shortcut (as described here http://www.qgis.org/en/docs/pyqgis_developer_cookbook/snippets.html) and a button I created on the toolbar. The button ...
0
votes
0answers
15 views

What's the conversion coefficient between millimeters and QSize units in Qgis?

What is the conversion coefficient between millimeters and QSize units in Qgis ? What i have in mind is to set the paper size (via setPaperSize()), knowing the size of the composed image. That is why ...
0
votes
1answer
17 views

how to compile qgis-1.8.0 on ubuntu

i have downloaded qgis-1.8.0.tar.bz2 and I want to install it on my linux computer(12.04 LTS). How can I perform it please? I do it because I am desperate with Qgis 2.0.1 Dufour on ubuntu 12.04, ...
0
votes
0answers
13 views

random point through raster

I've some issue in some task pls help if you can as I've not good python skills. I've a raster with values from 5 to 97 and I want a python script which can scan the raster and generate random points ...
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 ...
2
votes
1answer
74 views

How to write a new layer to PostgreSQL from QGIS plugin

The PyQGIS cookbook states that QgsVectorFileWriter can write vector layers to any format supported by OGR: https://www.qgis.org/en/docs/pyqgis_developer_cookbook/vector.html#writing-vector-layers ...
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 ...
0
votes
0answers
27 views

How to apply categorized symbols to polygon layer with PyQgis?

I'm fetching a polygon layer from postgres like this: uri = QgsDataSourceURI() uri.setConnection("localhost", "5432", "mydb", "postgres", "xxx") uri.setDataSource("public", "my_table", "geom") lyr = ...
1
vote
0answers
42 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.
2
votes
1answer
48 views

How to properly establish a PostgreSQL connection using QgsCredentials

I'm trying to establish a Postgres connection using QgsCredentials as described here: How to access user credentials in database connection? The only problem is that I cannot establish a working ...
4
votes
0answers
61 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
2
votes
1answer
69 views

QGIS python - identify and highlight features programatically

In QGIS there is an option to select features of a selected layer using a "identify feature" tool. Then the feature get highlighted in a different color and attribute dialog is poping up. like that i ...
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
2answers
70 views

How to get the file paths of the loaded layers in a QGIS plugin?

I am very new to GIS, QGIS and Python so please bear with me. I am using QGIS 2.0 and I would like to develop a QGIS plugin that would display the raster layers of the main window in order to allow ...
1
vote
2answers
180 views

How to perform SQL queries and get results from QGIS python console?

I'm writing a python script using QGIS API. I have to get results from postgres database table. The table has geometry field and other non-geometry fields. I want to perform SQL queries on ...
1
vote
1answer
78 views

How to find the polygons bordering a feature programmatically with qgis?

Is there a way to calculate the neighbors of a polygon with pyqgis for every feature? For example, the selected polygons relative to the one in the center: I found this solution, but it's a year ...
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) ...
0
votes
1answer
40 views

Halt QGIS on startup

I have a custom made login form in Python, which launches on QGIS startup. But before the user has a chance to enter the credentials, the program starts normally, bypassing the form. From then on the ...
2
votes
0answers
153 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 ...
1
vote
1answer
48 views

How can I add grid lines to a print composition using pyqgis?

I'm writing a qgis plugin to create an image in the print composer of the current map. I can get the map rendered in the proper place with a frame of the right width, and I can get grid annotations ...