the new qgis plugin allows to change the datasource of layers already loaded preserving all properties and settings (symbology, labels, joins, relations) using methods already exposed. The plugin operates in two operating modes: per layer or per project. In the first way it is possible to operate directly on layer right clicking on legend items, modifying the datasource type and string and applying the edits.
in the second way clicking on toolbar icon, the plugin exposes on an editable table datasource types and connection strings for all the loaded layers allowing global edits with a find and replace function or a direct edit on the cells. Datasource are not modified directly; modified cells are marked in yellow and the edits have to be applied to be effective, and visible on map canvas. Valid edits are marked in green while the invalid ones in red.
New release for postgisQueryBuilder. The plugin is aimed to to provide a friendly environment to perform spatial analysis in postgresql/postgis without having to deal with SQL code. It is not intented to replace the Qgis built-in DBManager that have a wide usage that covers all aspects of Qgis/Postgis interaction. It can be used in educational environments for a live analysis of the structure of the common spatial queries. The plugin can manage postgresql views and can be used for deploying spatial analysis frameworks based on chains of spatial relations.
- The UI has been completely redesigned to fit in a vertical dockable widget splitting functions in six tabbed slots: CONNECTION, QUERY, FILTER, SQL, TABLE, HISTORY
- New function on db objects: layer information rename, move to another schema, editing views sql definition
- geometry validation
- auto detecting of primary key and geometry fields
- many bug fixes (thanks to nejctrdin, EDiLD)
1) Map rotation support
2) Bing bird’s eye connection issues fixed
3) Proxying issues fixed
4) Proxying subnet exclusions fixed
5) Line and polygon infolayer support
6) Select and edit attributes from info layers
7) A4 keymap pdf printing
8) Buttons toolbar compacted
9) Map follows streetview option
Layer board plugin allows to change main layer properties such as name, crs and max and min visual scales. Michaël Douchin, the plugin developer, merged a pull request provided to modify datasource field as from previous post.
The source|uri field can be edited to point the layer to a different file/connection. The string has to declare the datasource type (ogr, spatialite, postgis, oracle, mysql …) separated with “|” (pipe) from the uri of the datasource.
For Ogr datasources the uri is absolute system path to the file. For other datasurces the uri consists in a connection string that is possible to retrieve from the layer source string reported in layer properties.
The plugin verifies if the target layer is valid and has a compatible geometry type before accept uri|source edits. Anyway, as any other layer property, the datasource changes have to be applied to be available. When applying the layers are reloaded taking care of all layer settings (style, joins , filters …)
Tutorial on youtube
From release 2.10 QGis Api include QgsVectorLayer::setDataSource method that makes obsolete the instructions cointained in the post for vector layers. For raster layers the method is still valid.
Qgis miss a Arcgis feature of which there is sometimes the need. The vector layer datasource can be changed to point another table keeping related settings and options (graphic styles, labels, join and related relation).
In Qgis there is a workaround method to set datasource editing the content of the qgis project (an XML file) file to modify layers datasource tag: http://gis.stackexchange.com/questions/62610/changing-data-source-of-layer-in-qgis and reloading project.
But in python it is possible to directly modify datasource using QgsVectorLayer.writeLayerXML and QgsVectorLayer.readLayerXML modifying the DOM document on the fly and reloading layer as from example below.
from PyQt4.QtXml import *
from qgis.core import *
from PyQt4.QtXml import *
layer = self.iface.legendInterface().currentLayer()
newDatasource = "NEW DATASOURCE STRING" # get datasource from layer properties general tab
newDatasourceProvider = "ogr" # possible values: ("ogr", "memory", "postgres", "spatialite")
# read layer DOM definition
XMLDocument = QDomDocument("style")
XMLMapLayers = QDomElement()
XMLMapLayers = XMLDocument.createElement("maplayers")
XMLMapLayer = QDomElement()
XMLMapLayer = XMLDocument.createElement("maplayer")
# modify DOM element with new layer reference
# reload layer definition
# apply to canvas and legend
The feature has been included in PickLayer plugin that allows to perform actions on clicked layer and feature
A qgis plugin for sketching and drawing on map canvas. It is intended for quick annotations and field use. Sketches can be drawn in different colors and widths and can be converted in memory layer if needed. The sketches are stored in the project directory in a separate .sketch txt file that can be shared with other users.
Tutorial on Youtube