getWikiMedia.ImageInfo | R Documentation |
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)
imagename |
Wikimedia commons unique image title |
APIsource |
location of the API service |
module |
default module |
details |
detailed parameters of interest |
testURL |
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.
Tomislav Hengl
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; ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.