library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0      ✔ purrr   1.0.1 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.3.0      ✔ stringr 1.5.0 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(terra)
## terra 1.7.3
## 
## Attaching package: 'terra'
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
library(tmap)
library(sf)
## Linking to GEOS 3.10.2, GDAL 3.4.2, PROJ 8.2.1; sf_use_s2() is TRUE

Creating rasters

T1 = rast("T1.tif")
T2 = rast("T2.tif")

Create Kitsap

Kitsap = terra::merge(T1,T2)

Examine Kitsap

Kitsap
## class       : SpatRaster 
## dimensions  : 3729, 5074, 1  (nrow, ncol, nlyr)
## resolution  : 30, 30  (x, y)
## extent      : 423893.3, 576113.3, 5205026, 5316896  (xmin, xmax, ymin, ymax)
## coord. ref. : NAD_1983_UTM_Zone_10N (EPSG:26910) 
## source(s)   : memory
## name        :         T1 
## min value   :   -6.46504 
## max value   : 2419.04004
summary(Kitsap)
## Warning: [summary] used a sample
##        T1          
##  Min.   :  -2.066  
##  1st Qu.:  57.008  
##  Median : 126.174  
##  Mean   : 341.647  
##  3rd Qu.: 483.351  
##  Max.   :2402.752  
##  NA's   :1360
ncell(Kitsap)
## [1] 18920946

TMAP

breaks = c(-20,20,50,75,100,200,500,2500)
tm_shape(Kitsap) +
  tm_raster(breaks = breaks,midpoint = NA)
## stars object downsampled to 1167 by 858 cells. See tm_shape manual (argument raster.downsample)

Histogram

hist(Kitsap)
## Warning: [hist] a sample of5% of the cells was used (of which 1% was NA)

Transformation

SQKitsap = sqrt(Kitsap)
summary(SQKitsap)
## Warning: [summary] used a sample
##        T1        
##  Min.   : 0.000  
##  1st Qu.: 7.594  
##  Median :11.249  
##  Mean   :14.718  
##  3rd Qu.:22.046  
##  Max.   :49.018  
##  NA's   :1604
class(SQKitsap)
## [1] "SpatRaster"
## attr(,"package")
## [1] "terra"
hist(SQKitsap)
## Warning: [hist] a sample of5% of the cells was used (of which 2% was NA)

An Alternative Graphic

ml = tm_shape(SQKitsap) +
  tm_raster(style = "cont",
            palette = "YlGnBu") +
  tm_layout(legend.show = F,
            title = "SQRT")

m = tm_shape(Kitsap) +
  tm_raster(style = "cont",
            palette = "YlGnBu") +
  tm_layout(legend.show = F,
            title = "Raw") 

tmap_arrange(m,ml)
## stars object downsampled to 1167 by 858 cells. See tm_shape manual (argument raster.downsample)
## stars object downsampled to 1167 by 858 cells. See tm_shape manual (argument raster.downsample)
## stars object downsampled to 1167 by 858 cells. See tm_shape manual (argument raster.downsample)
## stars object downsampled to 1167 by 858 cells. See tm_shape manual (argument raster.downsample)

See Kitsap #I could not find the file in my system.

#load("kitsap_sf.Rdata")