-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#107] added function geoshapesExport
this function provides a provisory export of geo shapes from the folder data/geo.
- Loading branch information
1 parent
5641a7f
commit 4cac992
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
geoshapesExport <- function(sormas_db){ | ||
# This function outputs a table containing geoshapes of each district. | ||
|
||
## Provisory geo shapes export: | ||
# Loading geoshapes from folder, not part of SORMAS data for now | ||
# geo_shapes data needs to be placed in data/geo folder and table key needs | ||
# to be placed in data/key folder. | ||
# data source: https://gadm.org/download_country.html | ||
|
||
files_geo <- list.files('data/geo', full.names = TRUE) | ||
|
||
# Reading in geo_shapes data | ||
geoshapes_data <- readRDS(files_geo) %>% | ||
dplyr::select(NAME_2, geometry) %>% | ||
dplyr::rename(district_name_geo = NAME_2) | ||
|
||
## Merging geo data and sormas district names using a table key | ||
|
||
# Loading key table from folder | ||
files_key <- list.files('data/key', full.names = TRUE) | ||
|
||
# Reading in key table | ||
key <- readxl::read_xlsx(files_key) | ||
|
||
# Merging key and geo_shapes data | ||
geoshapes_data <- key %>% | ||
dplyr::left_join(., geoshapes_data, by = 'district_name_geo') # joining w/ the matching key | ||
|
||
#returning output table | ||
return(geoshapes_data) | ||
} |