USAID-OHA-SI / gisr

OHA Geospatial Analytics Utilities
https://usaid-oha-si.github.io/gisr/
MIT License
2 stars 0 forks source link

Extract OU/Country specific geodata #9

Open baboyma opened 2 years ago

baboyma commented 2 years ago

@tessam30 to add details ...

tessam30 commented 2 years ago

Return country-level polygons in a list with elements being adm0, snu1, psnu etc or relevant layers to a given ou.

#' Fetch Zambia Polygons
#'
#' @param shpdata path where the VcPepfarPolygons live
#'
#' @return list of spatial data frames
#' @export
#'
#' @examples
#' \dontrun{
#' shpdata <- glamr::si_path("path_vector")
#' zmb_polygons(shpdata)
#' }
#'
ou_polygons <- function(shpdata = shpdata){

  cntry <- "Zambia"
  spdf_pepfar <- gisr::get_vcpolygons(path = shpdata, name = "VcPepfarPolygons.shp")

  spdf <- gisr::get_attributes(country = cntry)

  spdf_pepfar %<>% left_join(spdf, by = c("uid" = "id"))

  zmb_geo <- purrr::map(3:5, ~spdf_pepfar %>%
                          gisr::extract_boundaries(country = cntry,
                                             level = .x))

  names(zmb_geo) <- list("adm0", "snu1", "psnu")
  return(zmb_geo)
}
baboyma commented 2 years ago

Implemented - function renamed to cntry_polygons