Skip to content

Commit

Permalink
moves ch15 to tmap4
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowosad committed Mar 25, 2023
1 parent 8afab30 commit 2a6f80d
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions 15-eco.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,29 @@ Visualizing the data helps to get more familiar with it, as shown in Figure \@re
# tm_layout(inner.margins = 0, legend.outside = TRUE)
# tmap_save(tm, "figures/15_sa_mongon_sampling.png",
# width = 12, height = 7, units = "cm")
# if (packageVersion("tmap") >= "4.0"){
# hs = terra::shade(terra::terrain(dem, v = "slope", unit = "radians"),
# terra::terrain(dem, v = "aspect", unit = "radians"),
# 10, 200)
# library(tmap)
# tm = tm_shape(hs) +
# tm_grid(n.x = 3, n.y = 3) +
# tm_raster(col.scale = tm_scale_continuous(values = rev(hcl.colors(99, "Grays"))),
# col.legend = tm_legend_hide()) +
# tm_shape(dem) +
# tm_raster(col_alpha = 0.5,
# col.scale = tm_scale_continuous(n = 11, values = terrain.colors(50)),
# col.legend = tm_legend(title = "m asl", reverse = TRUE)) +
# tm_shape(study_area) +
# tm_borders() +
# tm_shape(random_points) +
# tm_symbols(col = "black", size = 0.2) +
# tm_layout(legend.position = tm_pos_auto_out())
# tmap_save(tm, "figures/15_sa_mongon_sampling.png",
# width = 12, height = 7, units = "cm")
# }
knitr::include_graphics("figures/15_sa_mongon_sampling.png")
```

Expand Down Expand Up @@ -556,6 +579,7 @@ pred = terra::predict(ep, model = autotuner_rf, fun = predict)
# terra::mask(terra::vect(study_area))
# pred = terra::mask(pred, terra::vect(study_area)) |>
# terra::trim()
#
# library(tmap)
# pal = rev(hcl.colors(n = 15, "RdYlBu"))
# tm = tm_shape(hs) +
Expand All @@ -570,6 +594,24 @@ pred = terra::predict(ep, model = autotuner_rf, fun = predict)
# tm_layout(inner.margins = 0.02, legend.outside = TRUE)
# tmap_save(tm, "figures/15_rf_pred.png",
# width = 12, height = 7, units = "cm")
# if (packageVersion("tmap") >= "4.0"){
# library(tmap)
# pal = rev(hcl.colors(n = 15, "RdYlBu"))
# tm = tm_shape(hs) +
# tm_grid(n.x = 3, n.y = 3, lines = FALSE) +
# tm_raster(col.scale = tm_scale_continuous(values = rev(hcl.colors(99, "Grays"))),
# col.legend = tm_legend_hide()) +
# tm_shape(pred, is.main = TRUE) +
# tm_raster(col.scale = tm_scale_continuous(values = pal, midpoint = NA),
# col.legend = tm_legend(title = "NMDS1", reverse = TRUE),
# col_alpha = 0.8) +
# tm_shape(study_area) +
# tm_borders() +
# tm_layout(legend.position = tm_pos_auto_out())
# tmap_save(tm, "figures/15_rf_pred.png",
# width = 12, height = 7, units = "cm")
# }
knitr::include_graphics("figures/15_rf_pred.png")
```

Expand Down

0 comments on commit 2a6f80d

Please sign in to comment.