Home > Back-end >  Display aerial photographs interactively in R
Display aerial photographs interactively in R

Time:02-11

I have taken aerial photographs with a drone and stitched those together into a .geotiff file, using third party software. I would like to add this file as a layer to an interactive leaflet map, e.g. as produced by mapview. I can produce an interactive map, but this only shows data, e.g. digital elevation not the actual photograph.

.geotiff files aren't very freely available, so see this link for an example file from naturalearth: https://www.naturalearthdata.com/downloads/50m-raster-data/50m-cross-blend-hypso/

library(magrittr)

exmpl <- terra::rast(".\\HYP_50M_SR.tif") %>% 
  raster::brick()

mapview::mapview(exmpl)

I am only interested in showing change over time as documented by repeated aerial photography and not interested in extracting data from the raster image. I have previously only worked with vector data, so please go easy on me if this is not a smart question. I like using mapview for it's simplicity, but base leaflet, tmap or any other interactive, R based solution would be fine by me. Thanks a lot!

CodePudding user response:

I guess you ar looking for the mapview::viewRGB() function.

Please find below a little reprex.

Reprex

library(mapview)
library(magrittr)

exmpl <- terra::rast(".\\HYP_50M_SR.tif") %>% 
  raster::brick()

plotRGB(exmpl)

mapview::viewRGB(exmpl, r = 1, g = 2, b = 3, quantiles = NULL)

Created on 2022-02-10 by the reprex package (v2.0.1)

  • Related