Last chance! 50% off unlimited learning
Sale ends in
getWikiMedia.ImageInfo
function fetches the EXIF (Exchangeable image file format) data via the Wikimedia API for any donated image. The resulting EXIF data (named list) can then be further used to construct an object of class "SpatialPhotoOverlay"
, which can be parsed to KML.
getWikiMedia.ImageInfo(imagename,
APIsource = "https://commons.wikimedia.org/w/api.php",
module = "imageinfo",
details = c("url", "metadata", "size", "extlinks"), testURL = TRUE)
Wikimedia commons unique image title
location of the API service
default module
detailed parameters of interest
logical; species if the program should first test whether the image exist at all (recommended)
Although this is often not visible in picture editing programs, almost any image uploaded to Wikimedia contains usefull EXIF metadata. However, it is highly recommended that you insert the some important tags in the image header yourself, by using e.g. the EXIF tool (courtesy of Phil Harvey), before uploading the files to Wikimedia. The getWikiMedia.ImageInfo
function assumes that all required metadata has already been entered by the user before the upload, hence no further changes in the metadata will be possible. Examples of how to embed EXIF tags into an image file are available here.
To geocode an uploaded image consider adding:
{{location|lat deg|lat min|lat sec|NS|long deg|long min|long sec|EW}}
tag to the file description, in which case getWikiMedia.ImageInfo
will automatically look for the attached coordinates via the external links. For practical purposes and because the image properties information determined by the Wikimedia system can are more reliable, the function will rewrite some important EXIF metadata (image width and height) using the actual values determined by Wikimedia server.
For a list of modules and parameters that can be used via getWikiMedia.ImageInfo
, please refer to Wikimedia API manual.
Wikimedia API (https://www.mediawiki.org/wiki/API)
EXIF tool (https://exiftool.org/)
spPhoto
, Rexif::getExifPy
# NOT RUN {
# Photo taken using a GPS-enabled camera:
imagename = "Africa_Museum_Nijmegen.jpg"
x <- getWikiMedia.ImageInfo(imagename)
# Get the GPS info:
x$metadata[grep(names(x$metadata), pattern="GPS")]
# prints the complete list of metadata tags;
# }
Run the code above in your browser using DataLab