2

The situation:

I create a project in QGIS. I use this project in a Data collection App, so that for each points I make several pictures.

The project is as follow:

  • a point layer (parent layer, point - geopackage);
  • a table layer (Child layer, no geometry type - geopackage -> attribute field ist set to "Attachment", type is "Image" and the path is set to "Relative to Project Path");
  • a relation (Project > Properties > Relations) 1-to-many between the points and the table -> referenced field used an UUID-key;

Relation also describe here: Input App showing only two pictures

My question is:

Once my project / one-to-many relation is set up and I have created few points in the App, how do you access my photos from the child layer in an Atlas/report/Print Layout?

More Details:

I know this is possible for Attribute Tables: in your Print Layout you can check "Generate an atlas" choose your Coverage layer and if this layer has a one-to-many relations set-up you can go under "source" choose "Relation Children" and select the "relation" you want. enter image description here enter image description here

What I have tried with:

Add a picture object in the atlas and under "Edit" use a function to "call" the first photo of the child layer. I would then repeat this with 2 or 3 pictures objects each calling a different picture of the child layer.

I know it should be something in this direction:

@project_folder||'\\DCIM\\' = array_get(
    aggregate('TableX',
              'array_agg',
              "Path",
               'Nfoto' =
                attribute(@parent,
                 'fid'))
 ,1)

The aggregate function is giving me Head Hecks and I was hoping for something similar to the attribute table solution...

1
  • 1
    In your aggregate function must compare the Nfoto field's value ("Nfoto" = ... ) instead of the Nfoto word or literal characters string ('Nfoto' = ... ). Also, the first element of the array has index 0 instead of 1. But maybe there are better ways to get the images. May 17 at 12:09

1 Answer 1

0

It has been a long time since I posted this question, but I still would like to thank you, Gabriel De Luca, for your help.

After much more research I found a solution to my problem using the "relation_aggregate" function. It goes as follow:

@project_folder || '//' || array_get( relation_aggregate(relation := '*RELATION'sID*', aggregate := 'array_agg', expression := "path") ,0)

I integrated 4 images in my Atlas and for the second, third and fourth I just change which element my array function calls.

So I get to keep my one to many relation and have the photos integrated in my Atlas. Of course with a one to many relation I can take much more than 4 photos but the extras are not required for my reports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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