Here's a super inelegant and embarassing function that should return lat long for an image.
 
imglatlong <- function(imgname)
 {
 x <- GDALinfo(imgname)
 xattr <- attr(x, "mdata")
 exiflong <- xattr[grep("EXIF_GPSLongitude=", xattr)]
 exiflat <- xattr[grep("EXIF_GPSLatitude=", xattr)]
 long <- as.numeric(gsub("^.*=\\(([0-9\\.]+)\\).*","\\1",exiflong)) + as.numeric(gsub("^.*=\\([0-9\\.]+\\) \\(([0-9\\.]+)\\).*","\\1",exiflong))/60 + as.numeric(gsub("^.*=\\([0-9\\.]+\\) \\([0-9\\.]+\\) \\(([0-9\\.]+)\\).*","\\1",exiflong))/3600
 long <- -(long)
 lat <- as.numeric(gsub("^.*=\\(([0-9\\.]+)\\).*","\\1",exiflat)) + as.numeric(gsub("^.*=\\([0-9\\.]+\\) \\(([0-9\\.]+)\\).*","\\1",exiflat))/60 + as.numeric(gsub("^.*=\\([0-9\\.]+\\) \\([0-9\\.]+\\) \\(([0-9\\.]+)\\).*","\\1",exiflat))/3600
 return(c(lat, long))
 }
 
latlong <- imglatlong("test.jpg")
 
Lee Elliott
Columbia, MO

> Date: Wed, 12 Jun 2013 13:11:54 +0000
> From: "Proosdij, Andre van" <andre.vanproosdij@wur.nl>
> Subject: [R-sig-Geo] Reading latitude longitude data from geotags
> Message-ID:
> 	<84D737939C16114590DCDD4F003E013B1FE20FF5@SCOMP0936.wurnet.nl>
> Content-Type: text/plain
> 
> Dear colleagues,
> 
> I want to read the latitude/longitude data from jpeg pictures. In the properties of the jpeg file, one can read the GPS coordinates in case the picture was taken using a camera with built-in GPS. Now I would like to use a R function to read these geotag data from the file and store it in a data.frame or matrix or other R object.
> .... 
> Ir. A.S.J. van Proosdij
> PhD Student
> t   +31 317 48 1198
> e  andre.vanproosdij@wur.nl<mailto:andre.vanproosdij@wur.nl>
> 

 		 	   		  
	[[alternative HTML version deleted]]

