ExifTool Forum

ExifTool => Newbies => Topic started by: Winfried on June 03, 2023, 02:42:45 PM

Title: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: Winfried on June 03, 2023, 02:42:45 PM
Hello,

Before I learn how to do this in Python, I'd like to check if ET can't do it on the command line.

I need to loop through all the JPGs in a directory (and its sub-directories), and find all the pictures that were taken within 50m from a lat+lon — and possibly build a GPX file with a link that I can just click to see the picture.

Can ET do this somehow?

Thank you.
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: StarGeek on June 04, 2023, 01:57:10 AM
I think it would be difficult to do the calculations directly on the command line. The problem on the command line would be having to access two different tags (the GPS coordinates) and then working in the center point coordinates and then the distance.

It probably would be possible to create a user defined tag, as I don't think the calculations would be that difficult, though I haven't looked into it.  But then, it also depends upon how accurate you want it to be.  Does it include the curvature of the earth or a simple direct line?  Does altitude enter in to it?
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: Winfried on June 04, 2023, 02:06:28 AM
Thanks.

Pictures are geotagged by my smartphone. It includes infos shown below. I don't need much accuracy: I just need to find which pictures were taken around a location, even if they're a bit a few meters aways from 50m.

GPSLatitudeRef - N
GPSLatitude - 48  47  29.3099 (48.791475)
GPSLongitudeRef - E
GPSLongitude - 2  15  9.8388 (2.252733)
GPSAltitudeRef - Above Sea Level
GPSAltitude - 212.13 m
GPSTimeStamp - 12  27  11
GPSDateStamp - 2023:06:03
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: sevy on June 04, 2023, 02:50:22 AM
may be a first approach here :
https://exiftool.org/forum/index.php?topic=11045.msg59031 (https://exiftool.org/forum/index.php?topic=11045.msg59031)
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: Winfried on June 04, 2023, 03:14:27 AM
Perfect!

c:\Apps\exiftool.exe -filename -if "$toRad=3.14159/180;$conv=6371*$toRad;(($gpslatitude#-$lat)*$conv)**2 + (($gpslongitude#-$lon)*$conv*cos($gpslatitude#*$toRad))**2 < $dist*$dist" -userparam lat=48.791475 -userparam lon=2.252733 -userparam dist=1 .
Google didn't help finding if "dist" can be set in meters. Kilometers isn't as useful for my need.

https://metacpan.org/dist/Image-ExifTool/view/lib/Image/ExifTool.pod#Options
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: StarGeek on June 04, 2023, 10:27:13 AM
Quote from: sevy on June 04, 2023, 02:50:22 AMmay be a first approach here :

Ah, you search was more successful than mine.  And I was over complicating things while thinking about it.

Quote from: Winfried on June 04, 2023, 03:14:27 AMGoogle didn't help finding if "dist" can be set in meters. Kilometers isn't as useful for my need.

Meters from Kilometers is easy, unlike Imperial measurements.  Just divide by 1000
-userparam dist=.05
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: Phil Harvey on June 06, 2023, 03:11:51 PM
Wouldn't it be

-userparam dist=0.001

to divide by 1000?

- Phil
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: StarGeek on June 06, 2023, 05:42:33 PM
Wouldn't that be 1 meter?  The first post says they want to be within 50 meters  50/1000=0.05
Title: Re: Loop through dirs and JPGs and list files that lie within 50m from a location?
Post by: Phil Harvey on June 06, 2023, 09:19:16 PM
Ah.  That's what I get for not reading the whole post.

- Phil