Dear all,

Thanks Lee Elliot for helping! I adjusted the script and now it works fine! Below the crucial part in which we added a line that corrects the positive/negative value for N vs S and E vs W.

imglonglat <- function(imgname)
{
  x <- GDALinfo(imgname)
  xattr <- attr(x, "mdata")
# Read the longitude and latitude values from the attribute data
  exiflong <- xattr[grep("EXIF_GPSLongitude=", xattr)]
  exiflat <- xattr[grep("EXIF_GPSLatitude=", xattr)]
# Convert the longitude and latitude to Deceimal Degrees
  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
  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
# Adjust the longitude and latitude according to N/S and E/W position
  if (any(grep("EXIF_GPSLongitudeRef=W", xattr))) long <- -(long)
  if (any(grep("EXIF_GPSLatitudeRef=S", xattr))) lat <- -(lat)
  return(c(imgname, long, lat))
}

You're welcome to test it and let me know if it works.

Best,


André


Ir. A.S.J. van Proosdij
PhD Student
t   +31 317 48 1198
e  andre.vanproosdij@wur.nl<mailto:andre.vanproosdij@wur.nl>

Naturalis Biodiversity Center, section NHN
Biosystematics Group, Wageningen University
Gen. Foulkesweg 37, 6703 BL Wageningen, the Netherlands

www.bis.wur.nl<http://www.bis.wur.nl/>

	[[alternative HTML version deleted]]

