Skip to content

Commit

Permalink
GLW, elevation, and grazing capacity commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wbagge committed Apr 13, 2023
1 parent d971910 commit 4e29dcc
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 1 deletion.
17 changes: 17 additions & 0 deletions R/get_elevation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param
#' @return
#' @author Whitney Bagge
#' @export
get_glw <- function() {

url_cattle <- "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/LHBICE#"
url_cattle_out <- GET(url_cattle)
unzipped_glw_cattle <- unzip(url_cattle_out)
Aw_layer <- if_else(str_detect(names(unzipped_glw_cattle), "Aw")==TRUE, )

}
18 changes: 18 additions & 0 deletions R/get_glw.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param
#' @return
#' @author Whitney Bagge
#' @export
get_glw <- function() {

url_cattle <- "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/LHBICE#"
#taxa cattle sheep goat have three urls here switch function (like if_else); have the three targets
url_cattle_out <- GET(url_cattle)
unzipped_glw_cattle <- unzip(url_cattle_out)
Aw_layer <- if_else(str_detect(names(unzipped_glw_cattle), "Aw")==TRUE, )

}
17 changes: 17 additions & 0 deletions R/get_grazingcap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param
#' @return
#' @author Whitney Bagge
#' @export
get_glw <- function() {

url_cattle <- "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/LHBICE#"
url_cattle_out <- GET(url_cattle)
unzipped_glw_cattle <- unzip(url_cattle_out)
Aw_layer <- if_else(str_detect(names(unzipped_glw_cattle), "Aw")==TRUE, )

}
16 changes: 16 additions & 0 deletions R/preprocess_glw.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param bounding_boxes
#' @return
#' @author Whitney Bagge
#' @export
preprocess_glw <- function(glw_layer, bounding_boxes) {

extent_object <- extent(bounding_boxes)
glw_layer_out <- crop(glw_layer, extent_object)
return(glw_layer_out)

}
17 changes: 17 additions & 0 deletions R/process_elevation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param bounding_boxes
#' @return
#' @author Whitney Bagge
#' @export
process_elevation <- function(elevation_layer_raw, bounding_boxes) {

extent_object <- extent(bounding_boxes)
elevation_layer_raw_out <- crop(elevation_layer_raw, extent_object)

return(elevation_layer_raw_out)

}
16 changes: 16 additions & 0 deletions R/process_grazingcap.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' .. content for \description{} (no empty lines) ..
#'
#' .. content for \details{} ..
#'
#' @title
#' @param bounding_boxes
#' @return
#' @author Whitney Bagge
#' @export
preprocess_glw <- function(glw_layer, bounding_boxes) {

extent_object <- extent(bounding_boxes)
glw_layer_out <- crop(glw_layer, extent_object)
return(glw_layer_out)

}
24 changes: 23 additions & 1 deletion _targets.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,29 @@ source_targets <- tar_plan(
},
repository = "local",
format = "file"
)
),

## GLW

tar_target(glw_cattle, get_glw()),
tar_target(glw_sheep, get_glw()),
tar_target(glw_goats, get_glw()),
tar_target(glw_cattle_preprocessed, preprocess_glw(glw_cattle, bounding_boxes)),
#need to cache

## ELEVATION

tar_target(elevation_layer_raw, get_elevation()),
tar_target(elevation_layer_processed,
process_elevation(elevation_layer_processed, bounding_boxes)),
#need to cache

## GRAZING CAPACITY

tar_target(grazingcap_raw, get_grazingcap()),
tar_target(grazingcap_processed,
process_grazingcap(grazingcap_layer_processed, bounding_boxes)),
#need to cache

)

Expand Down

0 comments on commit 4e29dcc

Please sign in to comment.