class: middle, title-slide # LAB: {STManaged} R package ### Willian Vieira <br><br><br><br><br> <i class="fa fa-github fa-2x" style="color:#335049"></i> [WillVieira/talk_biodiversityModeling2019](https://github.com/willvieira/talk_biodiversityModeling2019) <i class="fa fa-home fa-2x" style="color:#335049"></i> [https://willvieira.github.io/STManaged/](https://willvieira.github.io/STManaged/) --- class: inverse, center, middle # LAB ## {STManaged} R package --- ## LAB steps 1. Install package 2. Functions of the package 3. Understanding the package output --- ## STManaged R package: install <i class="fa fa-github fa-2x" style="color:#335049"></i> [WillVieira/talk_biodiversityModeling2019](https://github.com/willvieira/talk_biodiversityModeling2019) ```r devtools::install_github("willvieira/STManaged") ``` For Linux users, install `ImageMagick++` library before --- ## STManaged R package: main functions - Create the initial landscape ```r create_virtual_landscape() ``` - run the model ```r run_model() ``` --- ## STManaged R package: initial landscape ```r initLand <- create_virtual_landscape(climRange = c(-2.61, 5.07), cellSize = 1) ``` plot `initLand`: ```r plot_landscape(initLand, xaxis = TRUE) ``` <img src="index_files/figure-html/unnamed-chunk-2-1.png" style="display: block; margin: auto;" /> --- ## STManaged R package: run the model ```r lands <- run_model(steps = 20, initLand, managInt = c(0, 0, 0, 0), RCP = 8.5) ``` <!-- save(lands, file = 'GitHub/talk_biodiversityModeling2019/data/lands.Rdata')--> -- ```r names(lands) # [1] "land_T0" "land_T1" "land_T2" "land_T3" "land_T4" "land_T5" # [7] "land_T6" "land_T7" "land_T8" "land_T9" "land_T10" "land_T11" # [13] "land_T12" "land_T13" "land_T14" "land_T15" "land_T16" "land_T17" # [19] "land_T18" "land_T19" "land_T20" "env1" "steps" "manag" # [25] "RCP" "nCol" "nRow" ``` --- ## STManaged R package: output - landscape occupancy ```r par(mfrow = c(1, 2)) plot_occupancy(lands, step = 0, spar = 0.4) plot_occupancy(lands, step = 20, spar = 0.4) ``` <img src="index_files/figure-html/unnamed-chunk-5-1.png" style="display: block; margin: auto;" /> --- ## STManaged R package: output - animate temporal dynamic ```r animate(lands, fps = 2) ``` -- ![](images/RCP8.5_virtual.gif) --- class: inverse, center, middle # Using real landscape --- ## STManaged R package: initial landscape ```r initLand <- create_real_landscape() ``` plot `initLand`: ```r plot_landscape(initLand) ``` <img src="index_files/figure-html/unnamed-chunk-7-1.png" style="display: block; margin: auto;" /> --- ## STManaged R package: run the model ```r lands <- run_model(steps = 20, initLand, managInt = c(0, 0, 0, 0)) ``` Note: the only `RCP` scenario is `8.5` -- ```r names(lands) # [1] "lands" "steps" "manag" "RCP" "nCol" "nRow" class(lands[['lands']]) # [1] "RasterStack" # attr(,"package") # [1] "raster" names(lands[['lands']]) # [1] "land_T0" "tp" "pp" "land_T1" "land_T2" "land_T3" # [7] "land_T4" "land_T5" "land_T6" "land_T7" "land_T8" "land_T9" # [13] "land_T10" "land_T11" "land_T12" "land_T13" "land_T14" "land_T15" # [19] "land_T16" "land_T17" "land_T18" "land_T19" "land_T20" ``` --- ## STManaged R package: output - animate temporal dynamic ```r animate(lands, fps = 2) ``` -- .center[ ![:scale 85%](images/RCP8.5_real.gif) ]