"SpatialPhotoOverlay"spPhoto function can be used to wrap pixel map (pixmapRGB), PhotoOverlay (geometry) parameters to create an object of class "SpatialPhotoOverlay". This object can then be parsed to KML and visualized using Google Earth.spPhoto(filename, obj, pixmap, exif.info = NULL, ImageWidth = 0,
ImageHeight = 0, bands = rep(rep(1, ImageHeight*ImageWidth), 3),
bbox = c(0, 0, 3/36000*ImageWidth, 3/36000*ImageHeight),
DateTime = "", ExposureTime = "", FocalLength = "50 mm",
Flash = "No Flash", rotation = 0, leftFov = -30, rightFov = 30,
bottomFov = -30, topFov = 30, near = 50,
shape = c("rectangle", "cylinder", "sphere")[1], range = 1000, tilt = 90,
heading = 0, roll = 0, test.filename = TRUE)pixmap::pixmapRGB)"SpatialPhotoOverlay":"pixmapRGB" class)"SpatialPoints" class)SpatialPhotoOverlay for parsing to KML is to: (a) use the pixmap package, and reading the technical information via e.g. the Rexif} package. If the image is taken using a GPS enabled camera, by getting the EXIF metadata you can generate the complete SpatialPhotoOverlay object with minimum user interaction. Otherwise, you need to at least specify: creation date, file name, and location of the focal point of the camera (e.g. by creating "SpatialPoints" object).getWikiMedia.ImageInfo, pixmap::pixmapRGB, spMetadata# two examples with images on Wikimedia Commons
# (1) soil monolith (manually entered coordinates):
imagename = "Soil_monolith.jpg"
# import EXIF data using the Wikimedia API:
x1 <- getWikiMedia.ImageInfo(imagename)
# create a SpatialPhotoOverlay:
sm <- spPhoto(filename = x1$url$url, exif.info = x1$metadata)
# plot it in Google Earth
kml(sm, method="monolith", kmz=TRUE)
# (2) PhotoOverlay (geotagged photo):
imagename = "Africa_Museum_Nijmegen.jpg"
x2 <- getWikiMedia.ImageInfo(imagename)
af <- spPhoto(filename = x2$url$url, exif.info = x2$metadata)
kml(af)Run the code above in your browser using DataLab