lbusett / sprawl

sprawl - Spatial Processing (in) R: Amorphous Wrappers Library
https://lbusett.github.io/sprawl/
GNU General Public License v3.0
7 stars 1 forks source link

recategorize_rast: wrong behaviour on na.value = 0 #64

Closed lbusett closed 6 years ago

lbusett commented 7 years ago

RAT is wrongly modified when removing NA data.

Reprex:

library(sf)
library(dplyr)
in_ras <- read_rast("/home/lb/Google_Drive/My_Files/SIARL/SIARL_2014.tif")

in_bg <- get_boundaries("ITA", 2) %>% 
  dplyr::filter(NAME_2 == "Bergamo")

in_ras_crop <- crop_rast(in_ras, 
                    in_bg, 
                    mask = T) %>% 

  class_matrix <- tibble::tribble(~start, ~end, ~new, ~label, ~color,
                          0,    1,   0, "Other"  ,  "black",     # values >=0 and < 1 will be set to NA
                          1,    2,   1,  "Mais", "yellow", # values >=1 and < 5 will be set to 1
                          2,    100, 0, "Other", "black" # values >=5 and < 7 will be set to 2
                          ) 

  recat <- recategorize_rast(in_ras_crop, class_matrix)
  plot_rast_gg(recat, na.color = "transparent", na.value = "grey20")