library(paws)
svc = s3(config = list(region = "eu-central-1"))
obj = svc$list_objects(Bucket = "raster-tiles-data")
sapply(obj$Contents, '[[', "Key")output
[1] "natearth_3857_cog.tif" "natearth_3857_cog_defl.tif"
R package leafem has recently gained a function to visualise cloud optimised raster data
addCOGFor details on how to install and use software needed to create cloud optimised raster data that can be visualised with this function, please see this tutorial.
In this tutorial we will introduce this function in detail and highlight the different options we can use to control appearance of the visualisations.
I’ve prepared an AWS S3 bucket with some COGs. Let’s see what is in the bucket.
library(paws)
svc = s3(config = list(region = "eu-central-1"))
obj = svc$list_objects(Bucket = "raster-tiles-data")
sapply(obj$Contents, '[[', "Key")[1] "natearth_3857_cog.tif" "natearth_3857_cog_defl.tif"
So let’s visualise
library(leaflet)
library(leafem)
natearth_url = "https://raster-tiles-data.s3.eu-central-1.amazonaws.com/natearth_3857_cog_defl.tif"
leaflet() %>%
addTiles(group = "osm") %>%
addCOG(
url = natearth_url
, group = "NatEarth"
, layerId = "natearth"
, opacity = 1
, resolution = 256
, autozoom = FALSE
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm")
, overlayGroups = c("NatEarth")
) |>
setView(0, 0, 2)But we can visualise any freely availbale COG, such as the ones provided by the OpenGeoHub project OpenLandMap.
ogh_url = "https://s3.eu-central-1.wasabisys.com/openlandmap/predicted1km/pnv_fapar_proba.v.jan_d_1km_s0..0cm_2014..2017_v0.1.tif"
leaflet() %>%
addTiles(group = "osm") %>%
addCOG(
url = ogh_url
, group = "fapar"
, layerId = "fapar"
, opacity = 1
, resolution = 256
, autozoom = FALSE
) %>%
addMouseCoordinates() %>%
addLayersControl(
baseGroups = c("osm")
, overlayGroups = c("fapar")
) |>
setView(0, 0, 2)