• Home
  • About
    • Michele Wiseman photo

      Michele Wiseman

      A passion for science and discovery.

    • Learn More
    • Email
    • Twitter
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Capturing GPS Data from iPhone Photos with R

25 May 2021

Reading time ~1 minute

ExifR

Does your research involve extensive geospacial imaging? If so, you might be interested in learning how to automatically retrieve GPS (and other) metadata from your photos using the handy R package exifr. This is a brief example on how to generate a metadata table from your iphone photos.

Set your working directory to wherever your photos of interest are.

#setwd("~/Pictures/Photos Library.photoslibrary/Masters/2021/05")       #Uncomment and change to your directory

Next, install and then load the required packages.

install.packages("dplyr")      #comment out if you have the package
install.packages("exifr")       #comment out if you have the package
install.packages("leaflet")     #comment out if you have the package

library(dplyr)    
library(leaflet)            
library(exifr)

Create a list of your .jpg files. Determine what metadata you want and customize it after the read_exif command. Different metadata options depend on what metadata your camera captures; however, the packages options can be found here.

files <- list.files(pattern = "*.JPG", recursive = TRUE)        #I've set mine to recursive as I have many subdirectories. * = wildcard.
dat <- read_exif(files, tags = c("filename", "DateTimeOriginal", "GPSLongitude","GPSLatitude","GPSTimeStamp"))     #Customize the metadata of interest in the parentheses

With your metadata labeled and loaded into a dataframe, you can now export it as a .csv or use the metadata with a package like leaflet (and openstreetmaps).

more coming soon



GPSGISRexifrleaflet Share Tweet +1