Skip to content

Commit

Permalink
change function to load country limits
Browse files Browse the repository at this point in the history
  • Loading branch information
MaIsAp committed Oct 6, 2023
1 parent f7e725d commit 29f612e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/SHI/scp_SHI_02_GetAOH.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ print(Sys.getenv("SCRIPT_LOCATION"))
options(timeout = max(60000000, getOption("timeout")))

packages <- c("rjson","remotes","dplyr","tidyr","purrr","terra","stars","sf","readr",
"geodata","gdalcubes","stacatalogue","rredlist","stringr")
"geodata","gdalcubes","stacatalogue","rredlist","stringr","rnaturalearth","rnaturalearthhires")

if (!"gdalcubes" %in% installed.packages()[,"Package"]) remotes::install_git("https://github.com/appelmar/gdalcubes_R.git")
if (!"stacatalogue" %in% installed.packages()[,"Package"]) remotes::install_git("https://github.com/ReseauBiodiversiteQuebec/stac-catalogue")
Expand Down Expand Up @@ -90,10 +90,10 @@ study_area <- data.frame(text=study_area_opt,
))

if(study_area$option == 1){
sf_area_lim1 <- gadm(country=country_code, level=0, path=tempdir()) |> st_as_sf() |> st_make_valid() # country
sf_area_lim1 <- ne_countries(country = country_code,returnclass = 'sf') |> st_make_valid() # country
}
if(study_area$option == 2){
sf_area_lim1 <- gadm(country=country_code, level=1, path=tempdir()) |> st_as_sf() |> st_make_valid() |> filter(NAME_1==region) # region in a country
sf_area_lim1 <- ne_states(geounit="canada",returnclass = 'sf') |> st_make_valid() |> filter(woe_name==region) # region in a country
}
if(study_area$option == 3){
sf_area_lim1 <- st_read(study_area_path) # user defined area
Expand Down

0 comments on commit 29f612e

Please sign in to comment.