Quick summary map showing model results at the 1km and 2.5km resolution on the same map.
notes - While the predictor data is the same (worldclim2, elevation data, etc) these are different models. So this direct comparsions is not just showcasing the difference in the resolution of the predictor datasets, it’s combining the differences in variable selection, random point selection when developing the models and different parameter weight of the model algorithm. Just keep this in mind.
pacman::p_load("terra", "leaflet")
# arizonica
r1k <- terra::rast("~/trueNAS/work/cwr_wildgrapes/data/Vitis/Vitis arizonica/run20241212_1k/results/prj_threshold.tif")
# r1k
r2.5k <- terra::rast("~/trueNAS/work/cwr_wildgrapes/data/Vitis/Vitis arizonica/run20241204/results/prj_threshold.tif")
# r2.5k
# Define a two-color palette
pal1 <- colorFactor(c("#FFFFFF00", "blue"), domain = c(0, 1),alpha = 0.7, na.color = NA)
pal2 <- colorFactor(c("#FFFFFF00", "red"), domain = c(0, 1),alpha = 0.7, na.color = NA)
# Create a leaflet map
leaflet() %>%
# Add OpenStreetMap as the basemap
addTiles(group = "OpenStreetMap") %>%
# Add the first raster layer with the custom palette
addRasterImage(r1k, opacity = 1, colors = pal1, group = "Raster 1k") %>%
# Add the second raster layer with the custom palette
addRasterImage(r2.5k, opacity = 1, colors = pal2, group = "Raster 2.5k") %>%
# Add layer control to toggle rasters on/off
addLayersControl(
baseGroups = c("OpenStreetMap"),
overlayGroups = c("Raster 1k", "Raster 2.5k"),
options = layersControlOptions(collapsed = FALSE)
) |>
addLegend(
pal = pal1,
values = c(0, 1),
title = "Raster 1km",
opacity = 0.7
) |>
addLegend(
pal = pal2,
values = c(0, 1),
title = "Raster 2.5km",
opacity = 0.7
)
## Warning in colors(.): Some values were outside the color scale and will be
## treated as NA
## Warning in colors(.): Some values were outside the color scale and will be
## treated as NA