changeDataSource plugin release 1.0

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.

Screenshot 2015-09-30 20.25.02Screenshot 2015-09-30 20.29.09

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.

changeDataSource1

Download plugin

Advertisements

postgisQueryBuilder v1.6.0

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.

CHANGELOG v1.6.0

  • 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 nejctrdinEDiLD)

Download

Cheat Sheet

go2streetview v6.5

v6.5 (27/7/2015)
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

infoLayer_sv2infoLayer_bing2print leaflet001

Download plugin

Changing datasource with Layer Board plugin

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

layerboard

Changing Qgis layer datasource with python

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")
layer.writeLayerXML(XMLMapLayer,XMLDocument)

# modify DOM element with new layer reference
XMLMapLayer.firstChildElement("datasource").firstChild().setNodeValue(newDatasource)
XMLMapLayer.firstChildElement("provider").firstChild().setNodeValue(newDatasourceProvider)
XMLMapLayers.appendChild(XMLMapLayer)
XMLDocument.appendChild(XMLMapLayers)

# reload layer definition
self.layer.readLayerXML(XMLMapLayer)
self.layer.reload()

# apply to canvas and legend
self.iface.actionDraw().trigger()
self.iface.legendInterface().refreshLayerSymbology(self.layer)

The feature has been included in PickLayer plugin that allows to perform actions on clicked layer and feature

contextmenu

changedatasource

Download Plugin

RedLayer Plugin

Clipboard01

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. toolbar

Tutorial on Youtube

Download plugin

go2streetview for ground mapping surveys

I report this interesting application plugin go2streetview for measuring coordinates of objects visible from different positions:

https://translate.google.it/translate?hl=it&sl=auto&tl=en&u=http%3A%2F%2F%D0%B3%D0%BE%D1%80%D0%BE%D0%B4%D1%88%D0%B0%D1%85%D1%82%D1%8B.%D1%80%D1%84%2Fnazemnoe-fotogrammetricheskoe-kartirovanie-obektov-s-pomoshhyu-google-streetview-qgis-i-modulya-go2streetview%2F

Thanks to the author for the great idea ….