Skip to content

Plot raster in grey scale #139

Answered by dieghernan
aloboa asked this question in Q&A
Mar 5, 2024 · 1 comments · 6 replies
Discussion options

You must be logged in to vote

I just realized that geom_spatraster_rgb() interpolates by default (interpolate = TRUE) while geom_spatraster() don't (interpolate = FALSE). Adjusting also the start and end color to black and white it is almost there:

require(terra)
#> Loading required package: terra
#> terra 1.7.71
require(tidyterra)
#> Loading required package: tidyterra
#> 
#> Attaching package: 'tidyterra'
#> The following object is masked from 'package:stats':
#> 
#>     filter
require(ggplot2)
#> Loading required package: ggplot2

r <- rast(system.file("ex/logo.tif", package="terra"))
crs(r) <- NULL

ggplot() +
  geom_spatraster_rgb(data = r[[1]], r =1, g=1, b=1) +
  coord_sf()

# Not quite but...
ggplot() +
  geom…

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@dieghernan
Comment options

@aloboa
Comment options

@dieghernan
Comment options

@dieghernan
Comment options

Answer selected by aloboa
@aloboa
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
📊 ggplot2 Issues related with the implementation of ggplot2 functionalities ❔ q&a Questions on the usage of tidyterra
2 participants