So you have taken advantage of the excellent exiftool to extract all GPS-related information from a folder of photos in JPG format and write it to a CSV file:
exiftool '-*GPS*' -ext jpg -csv . > outfile.csv
You’ve used R/folder to plot coordinates (latitude and longitude) before, but what about that tag called GPSImgDirection? It would be nice to have some sort of marker indicating which direction you were looking when the photo was taken.
For me, a Google search turned up hints, but not a single, obvious, simple solution to this problem (the generative AI effect? Time will tell…), so here’s what I’ve put together from various sources, esp. this StackOverflow post.
The most important points are:
- usage awesome icons() to create a direction icon that can be rotated
- add the icons to your map using promised Dogesomemarkers ()
Here is some sample code that uses the Font Awesome icon long up arrow. Since “up” (north) corresponds to zero degrees, a rotation is applied that corresponds to GPSImgDirection should result in the correct orientation for the marker. In this case, the GPS-related tags come from an iPhone 13.
library(readr)
library(leaflet)
library(sp)
outfile <- read_csv("outfile.csv")
# create dataset
# ugly but it works
dataset <- outfile %>%
mutate(GPSLatitude = str_replace(GPSLatitude, " deg", "d"),
GPSLatitude = GPSLatitude %>%
char2dms() %>%
as.numeric(),
GPSLongitude = str_replace(GPSLongitude, " deg", "d"),
GPSLongitude = GPSLongitude %>%
char2dms() %>%
as.numeric(),
GPSHPositioningError = str_replace(GPSHPositioningError, " m", ""),
GPSHPositioningError = GPSHPositioningError %>%
as.numeric()) %>%
select(latitude = GPSLatitude,
longitude = GPSLongitude,
GPSTimeStamp,
GPSImgDirection,
GPSHPositioningError)
# create the marker icons
icons <- awesomeIcons(iconRotate = dataset$GPSImgDirection,
icon = "long-arrow-up",
library = "fa",
markerColor = "white",
squareMarker = TRUE)
# create map
# can filter on positioning error if desired
leaflet(data = dataset %>%
addProviderTiles(provider = providers$CartoDB.Positron) %>%
addAwesomeMarkers(icon = icons, label = ~GPSTimeStamp)
Here is a screenshot of the resulting interactive map.
Related
#Directional #marks #Rfolder #bloggers


