Combinig QGIS and leaflet to visualize an area with pictures

المشرف العام

Administrator
طاقم الإدارة
The goal of this post is to explain, based on practical examples from my professional activities, how I use QGIS, its plugin photo2Shape and the processing toolbox, together with geospatial packages of R (e.g. the package ‘leaflet’) to exploit efficiently georeferenced pictures.


I’m working within a team for a LIFE+ biodiversity project called ‘LIFE Elia’ whose aim is to carry out actions that increase biodiversity under high tension lines. We work along 160 km of electric lines in Belgium and in 7 sites in France for 4 years now and, to date, we changed more than 285 ha by execution of apropriate management solutions of the local habitat and rising partnerships (visit our website for further information). During our field job we document our sites with a lot of georeferenced pictures taken with GPS, tablet, smart phone or regular camera. As we already collected more than 5500 georeferenced pictures, it became a necessity to develop some convenient tools to manage and use them for our daily activities as well as for a general audience presentation on our website.

This post doesn’t aim to explain the great QGIS plugins that can be used to generate web map, such as qgis2web or qgis2leaf but I just share some examples of tools I’m using and how the results look like.

Need a convenient access to our pictures collection in QGIS

So far I was using ‘actions‘ and eVis to open pictures by clicking points on a layer produced by the plugin photo2Shape. It works great but when you have thousands of items in your layer, it’s becoming quickly not so convenient to open-&-close them one by one… Then Riccardo posted 2 months ago how to show photos in QGIS with mouse hovering using the map tips tool! This tip was a great solution for me to explore pictures on-the-fly and finally open the one(s) we need, as you can see in this short screen cast:



To display each point as a marker showing the date (year with 2-digits), I choose a categorized classification of the following expression: left(“img_date”,4) .* img_date and gps_date are attributes produced by photo2Shape and it might be better to use gps_date instead of img_date, it depends on how the meta-data of the pictures are collected by photo2Shape.

In the properties of the layer, the map tip displaytext is filled with this code:

Commune: [%"Comm"%]; Année: [% left("img_date" ,4)%] ; Mois: [% substr( "img_date",6,2)%][%CONCAT('
')%]Nom fichier: [% "filename" %][%CASE WHEN* "Replic" > 1 THEN (' (' || "Replic" || ' photos superposées!)') ELSE '' END%] Image source can be also defined as [%CONCAT(‘src=”/your/local/path/’,”filename”,'” width=”300″>’)%] in case of sharing a common folder on different computers (that’s our case) and the ‘width’ argument is useful to specify a unique size to all pictures.

Note that the attributes ‘Comm’ (= the name of the “commune” the point falls in) and ‘Replic’ (= how many points are stacked over each other) are automatically calculated by the following R code included as .rsx file in the processing toolbox. In the end of the screencast, one point shows 1 picture but hides 7 others, that’s why I open them later with eVis.

##[LIFE_Photos_Georef]=group##layer=vectorsetwd("/home/jf/Dropbox/CARTOGRAPHIE/02-Couches references")library('rgeos')# Script to reshape and fill point layer made by photo2Shape# Add a column 'commune'comm
 
أعلى