[Qgis-user] Show multiple photos attached to one feature

Brent Wood Brent.Wood at niwa.co.nz
Fri Oct 16 21:55:05 PDT 2020


Hi Sophia,

I suggest you set up a QGIS Action on the layer to view the images for a feature.

For a single feature, your data needs to contain a field with all the image names space separated (so no whitespace within names unless you want to make life difficult!!).

The action will be a batch file (Windows - painful, or Powershell) or script (Linux/Mac - easy) concatenate the path to each filename, then open each file with an image viewer.

eg:
a point feature has this text as a field (called filename):
P1010005.JPG P1020700.JPG
(the names of two pictures associated with the point feature)

I write a simple shell script (I'm on Linux) to iterate through a list of files (I called it open_images):
#! /bin/bash
#
# iteratively opens images passed on the command line
#
FILES=$@

for FILE in $FILES ; do
    eom /home/baw/Pictures/$FILE
done

The bash script sets the "$FILES" variable to store the list passed on the command line ($@)
It then uses the eom program (simple Linux image viewing program) to iteratively open each file in the list,
  prepending the path to the file for each one.

In QGIS, I create an Action on this layer called "open image", it contains the command:
/home/baw/qgis/open_images [%filename%]
This is the path to my my script, followed by the list of image names.

So, if I then select the action tool in QGIS, when I click on a feature on the canvas, QGIS runs the command as set up in the action, which is my script. It passes the contents of the "filename" field for the feature as a command line parameter. (essentially runs the command: /home/baw/qgis/open_images P1010005.JPG P1020700.JPG

The script then shows the first file, then the second, etc. whenever you click on a feature in QGIS. You can have a list with as many images per feature as you like (within reason... 30000 might be a problem!!


Hope this helps, I find the Action tool very useful for this sort of thing. Not quite as easy in Windows, which is not primarily a command line setup, but can still be done.


Cheers

Brent Wood

Principal Technician, Fisheries
NIWA
DDI:  +64 (4) 3860529

________________________________
From: Qgis-user <qgis-user-bounces at lists.osgeo.org> on behalf of chris hermansen <clhermansen at gmail.com>
Sent: Saturday, October 17, 2020 16:20
To: sophia couchman <choccycouchman at iname.com>
Cc: qgis-user <qgis-user at lists.osgeo.org>
Subject: Re: [Qgis-user] Show multiple photos attached to one feature

Sophia and list,

On Fri, Oct 16, 2020, 06:20 sophia couchman <choccycouchman at iname.com<mailto:choccycouchman at iname.com>> wrote:
Hi All,

I have mapped individual trees in a wood using QGIS and QField in a Layer called Trees.  Each Tree/Feature contains a number of fields.  I included a field for taking photographs and for each tree I took a number of photographs, anywhere from 2 to 6.

I then brought the QField data onto the computer.  When I right click on an individual feature using the Identify Features arrow the Identify Results box appears.  It contains all the fields including the photo field but this contains only one photograph in this format- DCIM/trees_20201010165100197.jpg but not the rest.  How can I have the rest of the photographs listed here too?

I think that if you have up to six photos you are going to need up to six fields to put them in, are you not?

Alternatively you could have a oneto zero or many relationship between your tree table and a separate photo table, which may be more difficult for you to manage.

Some databases will support an array of items but not sure if / how that is manifested in QGIS.

Chris
[https://www.niwa.co.nz/static/niwa-2018-horizontal-180.png]<https://www.niwa.co.nz>
Brent Wood
Principal Technician - GIS and Spatial Data Management
Programme Leader - Environmental Information Delivery
+64-4-386-0529 |
National Institute of Water & Atmospheric Research Ltd (NIWA)
301 Evans Bay Parade Hataitai Wellington New Zealand
Connect with NIWA: niwa.co.nz<https://www.niwa.co.nz> Facebook<https://www.facebook.com/nzniwa> LinkedIn<https://www.linkedin.com/company/niwa> Twitter<https://twitter.com/niwa_nz> Instagram<https://www.instagram.com/niwa_science>
To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20201017/010aa611/attachment.html>


More information about the Qgis-user mailing list