{"id":1070,"date":"2022-04-11T15:55:18","date_gmt":"2022-04-11T13:55:18","guid":{"rendered":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/?p=1070"},"modified":"2022-04-11T18:36:37","modified_gmt":"2022-04-11T16:36:37","slug":"visualizing-plant-collection-sites-on-a-map","status":"publish","type":"post","link":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/2022\/04\/11\/visualizing-plant-collection-sites-on-a-map\/","title":{"rendered":"Visualizing plant collection sites on a map"},"content":{"rendered":"<p><strong>Image metadata can be both scary and useful<\/strong><\/p>\n<p>Assume that you are a field botanist on an expedition and that you take photographs of every collection site that you visit. The metadata that is routinely stored as part of your photograph can be used to visualize your collection sites on a map. For example, the following photograph that I took while collecting plants on a bike trip has the following GPS metadata:<\/p>\n<div id=\"attachment_1076\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-scaled.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1076\" class=\"wp-image-1076 size-medium\" src=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-300x225.jpg\" alt=\"Field trip by bike near Neuruppin\" width=\"300\" height=\"225\" srcset=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-300x225.jpg 300w, https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-1024x768.jpg 1024w, https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-768x576.jpg 768w, https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-1536x1152.jpg 1536w, https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/fieldtrip_image-2048x1536.jpg 2048w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1076\" class=\"wp-caption-text\">Field trip by bike near Neuruppin<\/p><\/div>\n<div style=\"background-color: #ffebdb\">\n<pre>GPS Latitude Ref           : North\r\nGPS Longitude Ref          : East\r\nGPS Altitude               : 123 m Above Sea Level\r\nGPS Date\/Time              : 2019:06:21 14:57:30Z\r\nGPS Position               : 53 deg 8' 56.52\" N, 13 deg 14' 18.04\" E\r\n<\/pre>\n<\/div>\n<p>A visualization via picture metadata is quite easy to achieve with R.<\/p>\n<p>First, you use the R package <a href=\"https:\/\/cran.r-project.org\/web\/packages\/exiftoolr\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">exiftoolr<\/a> to parse and extract the GPS metadata that may be stored as part of your field trip photographs. Notice that I use the function <em>exif_read()<\/em> to parse the metadata from all images in the image folder and that I remove all cases where no metadata was extracted from the images via function <em>na.omit()<\/em>.<\/p>\n<div style=\"background-color: #ffebdb\">\n<pre>library(exiftoolr)\r\ninData = exif_read(path=\"\/path_to_image_folder\/\", \r\n   recursive=TRUE, \r\n   tags=c(\"FileName\", \"GPSDateTime\",\"GPSLatitude\", \"GPSLongitude\"))\r\ninData = as.data.frame(inData)\r\ninData$SourceFile &lt;- NULL\r\nlocs = na.omit(inData[,c(\"GPSLatitude\",\"GPSLongitude\")])\r\n<\/pre>\n<\/div>\n<p>Second, you use the R package <a href=\"https:\/\/cran.r-project.org\/web\/packages\/ggmap\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">ggmap<\/a> to download a suitable map and to plot the latitude and longitude information that you extracted from the image metadata onto that map.<\/p>\n<div style=\"background-color: #ffebdb\">\n<pre>library(ggmap)\r\nlowerleftlon = min(locs[,2])-6*sd(locs[,2])\r\nlowerleftlat = min(locs[,1])-2*sd(locs[,1])\r\nupperrightlon = max(locs[,2])+6*sd(locs[,2])\r\nupperrightlat = max(locs[,1])+2*sd(locs[,1])\r\nbw_map = get_stamenmap(\r\n    bbox = c(left = lowerleftlon, \r\n             bottom = lowerleftlat, \r\n             right = upperrightlon, \r\n             top = upperrightlat), \r\n    zoom = 8, \r\n    maptype = \"terrain\",\r\n    color = \"bw\"\r\n)\r\nggmap(bw_map) +\r\n  geom_point(data = locs, \r\n             aes(x = GPSLongitude, y = GPSLatitude),\r\n             color=\"red\")\r\n<\/pre>\n<\/div>\n<p>The above procedure produced the following map for a two-day field trip conducted in 2019:<\/p>\n<div id=\"attachment_1078\" style=\"width: 159px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/ggmap_stamenmap.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1078\" class=\"size-medium wp-image-1078\" src=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/ggmap_stamenmap-149x300.png\" alt=\"Map of collection sites\" width=\"149\" height=\"300\" srcset=\"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/ggmap_stamenmap-149x300.png 149w, https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/files\/2022\/04\/ggmap_stamenmap.png 269w\" sizes=\"auto, (max-width: 149px) 100vw, 149px\" \/><\/a><p id=\"caption-attachment-1078\" class=\"wp-caption-text\">Map of collection sites<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Image metadata can be both scary and useful Assume that you are a field botanist on an expedition and that you take photographs of every collection site that you visit. The metadata that is routinely stored as part of your photograph can be used to visualize your collection sites on a map. For example, the [&hellip;]<\/p>\n","protected":false},"author":2306,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57599,57598],"tags":[],"class_list":["post-1070","post","type-post","status-publish","format-standard","hentry","category-audiovisual","category-bioinformatics"],"_links":{"self":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/1070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/users\/2306"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/comments?post=1070"}],"version-history":[{"count":8,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1081,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/posts\/1070\/revisions\/1081"}],"wp:attachment":[{"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.fu-berlin.de\/gruenstaeudl\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}