Last updated: 2021-05-19
Checks: 7 0
Knit directory: booksn_ppm/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210517)
was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 09971e1. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.DS_Store
Ignored: data/data_raw/
Untracked files:
Untracked: glmulti.analysis.modgen.back
Untracked: glmulti.analysis.mods.back
Unstaged changes:
Modified: analysis/computeDisparity.Rmd
Modified: analysis/computeMannKendall.Rmd
Modified: analysis/evolucionTemporal.Rmd
Modified: data/coplas2019sn.csv
Modified: output/comparaD_especies.pdf
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were made to the R Markdown (analysis/bufferSN.Rmd
) and HTML (docs/bufferSN.html
) files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view the files as they were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 30b0f35 | Antonio J Perez-Luque | 2021-05-18 | Build site. |
Rmd | 66b69f4 | Antonio J Perez-Luque | 2021-05-18 | add data of species |
html | 5ba1412 | Antonio J Perez-Luque | 2021-05-17 | Build site. |
Rmd | 5dfa4b7 | Antonio J Perez-Luque | 2021-05-17 | update repo |
html | 09743fc | Antonio J Perez-Luque | 2021-05-17 | Build site. |
Rmd | f6f2948 | Antonio J Perez-Luque | 2021-05-17 | select data for SN |
La idea es seleccionar un conjunto de parcelas en torno a Sierra Nevada de la forma menos subjetiva posible.
library("tidyverse")
library("here")
library("finch")
library("sf")
library("flextable")
library("DT")
sn <- st_read("data/data_raw/geoinfo/sn_enp.shp")
Reading layer `sn_enp' from data source `/Users/ajpelu/Google Drive/MS/books/2021_SN/booksn_ppm/data/data_raw/geoinfo/sn_enp.shp' using driver `ESRI Shapefile'
Simple feature collection with 1 feature and 10 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 442911.5 ymin: 4085480 xmax: 536730.7 ymax: 4123200
projected CRS: ED50 / UTM zone 30N
load(here::here("data/data_raw/mapa_rodales.RData"))
rodales <- st_as_sf(mapa.rodales) %>%
st_transform(crs = st_crs(sn)) %>%
st_make_valid()
rodal2019 <- st_read(here::here("data/data_raw/geoinfo/coberturas_procesionaria/COB270616_ETRS89.shp")) %>%
st_transform(crs = st_crs(sn)) %>%
st_make_valid()
Reading layer `COB270616_ETRS89' from data source `/Users/ajpelu/Google Drive/MS/books/2021_SN/booksn_ppm/data/data_raw/geoinfo/coberturas_procesionaria/COB270616_ETRS89.shp' using driver `ESRI Shapefile'
Simple feature collection with 4550 features and 11 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: 103172.9 ymin: 3991740 xmax: 599551.6 ymax: 4276615
projected CRS: ETRS89 / UTM zone 30N
Generamos varios buffers (10, 15, 20, 25 km) del límite de SN
Calculamos la cantidad de parcelas que caen en cada buffer, clasificadas por los niveles de elevación que hemos definido previamente.
ojo parece que había un problema con la seleccion que hacía de las parcelas (la capa que me paso Luis no se hacia bien la interseccion). Por ello hemos realizado esta operación con dos conjuntos de datos espaciales (es indiferente porque lo que queremos es ver que buffer elegir)
bufferiza <- function(parcelas, enp, d){
buffer <- st_buffer(enp, units::set_units(d, "km"))
namebuffer <- paste0('buffer_',d)
df <- st_intersection(parcelas, buffer) %>%
st_drop_geometry() %>%
# dplyr::select(code = `N.rodal`) %>%
mutate({{namebuffer}} := 1)
return(df)
}
i25 <- bufferiza(rodales, sn, 25) %>% dplyr::select(code = `N.rodal`, buffer_25)
i25b <- bufferiza(rodal2019, sn, 25) %>% dplyr::select(code = `N_CODIGO`, buffer_25)
i20 <- bufferiza(rodales, sn, 20) %>% dplyr::select(code = `N.rodal`, buffer_20)
i20b <- bufferiza(rodal2019, sn, 20) %>% dplyr::select(code = `N_CODIGO`, buffer_20)
i15 <- bufferiza(rodales, sn, 15) %>% dplyr::select(code = `N.rodal`, buffer_15)
i15b <- bufferiza(rodal2019, sn, 15) %>% dplyr::select(code = `N_CODIGO`, buffer_15)
i10 <- bufferiza(rodales, sn, 10) %>% dplyr::select(code = `N.rodal`, buffer_10)
i10b <- bufferiza(rodal2019, sn, 10) %>% dplyr::select(code = `N_CODIGO`, buffer_10)
df <- i25 %>%
full_join(i20) %>%
full_join(i15) %>%
full_join(i10)
dfb <- i25b %>%
full_join(i20b) %>%
full_join(i15b) %>%
full_join(i10b)
coplas2019 <- read_csv(here::here("data/coplas2019.csv"))
df_elev <- df %>%
left_join(coplas2019) %>%
dplyr::select(code, buffer_25:buffer_10, sp, elevF, sp_abrev, especie)
df_elevb <- dfb %>%
left_join(coplas2019) %>%
dplyr::select(code, buffer_25:buffer_10, sp, elevF, sp_abrev, especie)
n_parcelas <- df_elev %>%
group_by(elevF) %>%
summarise(across(starts_with('buf'), sum, na.rm = TRUE)) %>%
filter(!is.na(elevF))
n_parcelasb <- df_elevb %>%
group_by(elevF) %>%
summarise(across(starts_with('buf'), sum, na.rm = TRUE)) %>%
filter(!is.na(elevF))
DT::datatable(n_parcelasb)
exclude <- c("AL088001", "AL088002", "AL088003", "AL088004", "AL088005",
"AL088006", "AL078001", "AL078002", "AL078003", "AL074001",
"AL074002", "AL013001", "AL013002")
coplas.sn <- coplas2019 %>%
left_join(i20b) %>%
filter(!(code %in% exclude)) %>%
mutate(buffer_20 = case_when(
code %in% c("GR140011", "GR140013") ~ 1,
TRUE ~ buffer_20)) %>%
filter(buffer_20 == 1) %>%
dplyr::select(-buffer_20)
write_csv(coplas.sn, here::here("data/coplas2019sn.csv"))
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.3
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DiagrammeR_1.0.6.1 sp_1.4-5 DT_0.17 flextable_0.6.3
[5] sf_0.9-7 finch_0.4.0 here_1.0.1 forcats_0.5.1
[9] stringr_1.4.0 dplyr_1.0.4 purrr_0.3.4 readr_1.4.0
[13] tidyr_1.1.2 tibble_3.0.6 ggplot2_3.3.3 tidyverse_1.3.0
[17] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] fs_1.5.0 lubridate_1.7.10 RColorBrewer_1.1-2 httr_1.4.2
[5] rprojroot_2.0.2 tools_4.0.2 backports_1.2.1 bslib_0.2.4
[9] R6_2.5.0 KernSmooth_2.23-18 rgeos_0.5-5 DBI_1.1.1
[13] lazyeval_0.2.2 colorspace_2.0-0 withr_2.4.1 tidyselect_1.1.0
[17] curl_4.3 compiler_4.0.2 git2r_0.28.0 cli_2.3.0
[21] rvest_0.3.6 jsonld_2.2 xml2_1.3.2 officer_0.3.16
[25] sass_0.3.1 scales_1.1.1 classInt_0.4-3 rappdirs_0.3.3
[29] systemfonts_1.0.0 digest_0.6.27 rmarkdown_2.6.6 base64enc_0.1-3
[33] pkgconfig_2.0.3 htmltools_0.5.1.1 dbplyr_2.1.0 htmlwidgets_1.5.3
[37] rlang_0.4.10 readxl_1.3.1 rstudioapi_0.13 visNetwork_2.0.9
[41] jquerylib_0.1.3 generics_0.1.0 emld_0.5.1 jsonlite_1.7.2
[45] crosstalk_1.1.1 zip_2.1.1 magrittr_2.0.1 Rcpp_1.0.6
[49] munsell_0.5.0 gdtools_0.2.3 lifecycle_1.0.0 stringi_1.5.3
[53] whisker_0.4 yaml_2.2.1 jqr_1.2.0 grid_4.0.2
[57] EML_2.0.4 promises_1.2.0.1 crayon_1.4.1 lattice_0.20-41
[61] haven_2.3.1 hms_1.0.0 knitr_1.31 pillar_1.4.7
[65] uuid_0.1-4 reprex_1.0.0 glue_1.4.2 evaluate_0.14
[69] V8_3.4.0 hoardr_0.5.2 data.table_1.13.6 modelr_0.1.8
[73] vctrs_0.3.6 httpuv_1.5.5 cellranger_1.1.0 gtable_0.3.0
[77] assertthat_0.2.1 xfun_0.20 broom_0.7.4 e1071_1.7-4
[81] later_1.1.0.1 class_7.3-18 units_0.6-7 ellipsis_0.3.1