Scale bar
#119
Replies: 1 comment
-
Yes, it is possible via # Your example
library(terra)
#> terra 1.7.55
f <- system.file("ex/elev.tif", package = "terra")
r <- rast(f)
plot(r)
sbar(10, c(6.3, 50)) # With tidyterra and ggspatial
library(tidyterra)
library(ggplot2)
library(ggspatial)
ggplot() +
geom_spatraster(data = r) +
scale_fill_terrain_c() +
annotation_scale(style = "ticks") Or you may give a try to library(tmap)
#> Breaking News: tmap 3.x is retiring. Please test v4, e.g. with
#> remotes::install_github('r-tmap/tmap')
tm_shape(r) +
tm_raster(palette = terrain.colors(10, rev = TRUE)) +
tm_layout(legend.position = c("right", "TOP")) +
tm_scale_bar() Created on 2023-10-30 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to add a scale bar to plots, as in terra?
f <- system.file("ex/elev.tif", package="terra")
r <- rast(f)
plot(r)
sbar(10, c(6.3, 50))
Beta Was this translation helpful? Give feedback.
All reactions