1

In QGIS 3.14 / QfieldSync there is now the functionality to configure photo naming. Yay!

I use a 1:n set-up for photos, i.e. I capture photos in the child table ('photo') of a one-to-many relationship. I would like to name my photos based on attributes ('type' and 'num') in the parent layer ('tree').

So far, my attempt at the expression is as follows:

'DCIM/'||attributes(get_feature('tree','uuid','fkid'))['type'||'num']||'_'||now()||'.jpg'

This isn't working.

Any ideas?

2

okay, with much playing around, this is now working:

case
when "fkid" is null then 
    'DCIM/'||
    format_date(Now(), 'yyyyMMdd_hhmmss')||
    '.jpg'
else
    'DCIM/'||
    attributes(get_feature('tree_pt','uuid',"fkid"))['type']||
    attributes(get_feature('tree_pt','uuid',"fkid"))['num']||'_'||
    format_date(Now(), 'yyyyMMdd_hhmmss')||
    '.jpg'
end

Notes:

  • "fkid" is the foreign key in the photos layer.
  • 'tree_pt' is the parent layer
  • 'uuid' is the primary key in 'tree_pt'
  • note the use of single and double quotes.

In my set-up, anyone of three parent layers may store image paths in 'photos'. So I wrap this up in coalesce() to check each layer for a match. Much like Highlander, there can be only one: I am using uuid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.