knitr::opts_chunk$set(echo = TRUE, fig.width = 9)
Open the tmap repository as RStudio project. Set Knit Directory (via drop-down menu of the Knit button in RStudio) to Project Directory.
library(devtools) load_all() library(stars) library(terra) data(land) landsat_stars = read_stars(system.file("raster/landsat.tif", package = "spDataLarge")) landsat_terra = rast(system.file("raster/landsat.tif", package = "spDataLarge")) tif_stars = system.file("tif/L7_ETMs.tif", package = "stars") %>% read_stars() tif_terra = system.file("tif/L7_ETMs.tif", package = "stars") %>% rast() prec = read_ncdf(system.file("nc/test_stageiv_xyt.nc", package = "stars"), curvilinear = c("lon", "lat"), ignore_bounds = TRUE) nc = sf::read_sf(system.file("gpkg/nc.gpkg", package = "sf"), "nc.gpkg") %>% st_transform(st_crs(prec)) prec_nc = aggregate(prec, by = nc, FUN = max) weather = read_ncdf(system.file('nc/bcsd_obs_1999.nc', package = 'stars')) weather1 = st_set_dimensions(merge(weather), names = c('longitude','latitude','time','attributes')) weather2 = split(weather1, 'time') tmapV = ifelse(packageVersion("tmap") >= "3.4", "4", "3") txt = function(x) print(grid::grid.text(x, gp = gpar(cex = 3))) v3 = function(e) { if (tmapV == "3") { print(e) } else { txt("Only for tmap 3") } invisible(NULL) } v4 = function(e) { if (tmapV == "4") { print(e) } else { txt("Only for tmap 4") } invisible(NULL) } txt(paste("Loaded tmap version", tmapV))
tm_shape(land) + tm_raster()
tm_shape(landsat_stars) + tm_raster()
tm_shape(tif_stars) + tm_raster()
tm_shape(prec) + tm_raster()
tmap_options(max.raster = 50000) tm_shape(prec) + tm_raster()
tm_shape(prec) + tm_raster(col.scale = tm_scale_intervals(style = "kmeans"))
tm_shape(prec_nc) + tm_polygons("Total_precipitation_surface_1_Hour_Accumulation")
tm_shape(weather) + tm_raster()
tm_shape(weather1) + tm_raster()
tm_shape(weather2) + tm_raster()
#todo s1_rearrage_faetgs # 83 86 tm_shape(weather2) + tm_raster() + tm_facets_grid(rows = "attributes")
# testing non-made names tm_shape(weather2) + tm_raster(c("1999-02-28", "1999-03-31", "1999-04-30"))
# testing made names tm_shape(weather2) + tm_raster(c("X1999.02.28", "X1999.03.31", "X1999.04.30"))
tm_shape(landsat_stars) + tm_raster()
tmap_options(max.raster = 40) tm_shape(landsat_stars) + tm_raster()
tm_shape(landsat_terra) + tm_raster()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.