Select to view content in your preferred language

Getting exifInfo with arcade

1062
3
Jump to solution
11-28-2023 08:51 AM
Labels (1)
mikaël
Frequent Contributor

I wish to extract exif metadata (lat and long) from pictures taken and uploaded to a feature service on AGOL from a Survey123 form. I know I can do this directly in the XLSForm by using the pulldata("@exif") function, but I would prefer not adding more columns to my table (plus, the number of pictures that a user can take is multiple so I don't know how I would deal with the ensuing unknown multiple coordinates).

So I was thinking more of extracting the exif metadata with arcade (either in map viewer or dashboard), with attachments(value).exifInfo in a loop. I'm able to retrieve other metadata (name, id, contentType, and so on), but exifInfo seems to always be empty.

Searching a bit, I stumbled upon this thread which is based on HEIC format pictures. I thought this could be my case too, because workers on the field use iPads. However, I just tried sending out a form with a picture taken on an Android device and I have the same problem.

When I download the pictures (either taken from Android or iPad/iOS) from AGOL to my computer, the location is indeed present in the metadata. So my guess is i'm not using the attachments() function correctly.

For other metadata I do:

 

var features = [];
var att = attachments(e); //where e is $feature or is another var from a loop in a layer/table
if (count(att) > 0) {
    for (var a in att) {
        push(features, att[a].name) //works
        //push(features, att[a].exifInfo) >> always empty
        //also tried looping through att[a].exifInfo or manually att[a].exifInfo[0], att[a].exifInfo[1] and so on...
   }
return features;

 

Any idea what i'm doing wrong?

Thanks for your help!

0 Kudos
1 Solution

Accepted Solutions
mikaël
Frequent Contributor

Ended up contacting support and they provided the answer I was looking for.

I had to use parameter "metadata""metadata (Optional): Boolean - Indicates whether to include attachment metadata in the function return. Only Exif metadata for images is currently supported"

 

var att = attachments(e, {metadata: True});

 

Then I had to loop through a couple of dictionaries inside exifInfo but with trial and error I got the GPS coordinates.

View solution in original post

0 Kudos
3 Replies
mikaël
Frequent Contributor

Ended up contacting support and they provided the answer I was looking for.

I had to use parameter "metadata""metadata (Optional): Boolean - Indicates whether to include attachment metadata in the function return. Only Exif metadata for images is currently supported"

 

var att = attachments(e, {metadata: True});

 

Then I had to loop through a couple of dictionaries inside exifInfo but with trial and error I got the GPS coordinates.
0 Kudos
KatelynCline
New Contributor

hey! would you mind dropping the full code snippet that worked? I'm trying to do this as well (except I want to grab direction) but I'm always getting that empty return even with {metadata:true}. thanks!

mikaël
Frequent Contributor

hi,

Finally I didn't end up using this solution but I found this in my old notes:

 

var agol = portal("https://www.arcgis.com");
var layer = featuresetbyportalitem(agol, ITEM_ID, LAYER_ID_IN_SERVICE, ["*"], false);
var features = [];
for (var e in layer) {
  var att = attachments(e, {metadata: True})
    if (count(att) > 0)  {
      for (var a in att) {
        //here is where you loop in your exifInfo
        for (var i in att[a].exifInfo) {
          //here is where I believe you will be able to get the metadata
          //I don't remember what I was trying to check
          if (att[a].exifInfo[i].name == "Exif IFD0") {
            // "Exif SubIFD" // "GPS"
            push(features, att[a].exifInfo[i])
          }
        }
      }
    }
  }
}
return features

 

Check out this and this.

Hope this will help you and anybody else in the future!

0 Kudos