Title: | Download Colombian Demographic, Climate and Geospatial Data |
---|---|
Description: | Downloads wrangled Colombian socioeconomic, geospatial,population and climate data from DANE <https://www.dane.gov.co/> (National Administrative Department of Statistics) and IDEAM <https://ideam.gov.co> (Institute of Hydrology, Meteorology and Environmental Studies). It solves the problem of Colombian data being issued in different web pages and sources by using functions that allow the user to select the desired database and download it without having to do the exhausting acquisition process. |
Authors: | Maria Camila Tavera-Cifuentes [aut, cre, cph] , Julian Otero [aut, cph] , Natalia Nino-Machado [ctb] , Catalina Gonzalez-Uribe [ctb] , Juan Manuel Cordovez [ctb] , Hugo Gruson [rev] , Chris Hartgerink [rev] , Karim Mane [rev] , Joshua W. Lambert [rev] |
Maintainer: | Maria Camila Tavera-Cifuentes <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.1 |
Built: | 2024-11-17 06:12:19 UTC |
Source: | https://github.com/epiverse-trace/ColOpenData |
Aggregate time series downloaded climate data to day, month or year.
Only observations under the tags TSSM_CON
, TMN_CON
,
TMX_CON
, PTPM_CON
, and BSHG_CON
can be aggregated,
since are the ones where methodology for aggregation is explicitly provided
by the source.
aggregate_climate(climate_data, frequency)
aggregate_climate(climate_data, frequency)
climate_data |
|
frequency |
character with the aggregation frequency: ( |
data.frame
object with the aggregated data.
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) ptpm <- download_climate_geom(roi, "2022-11-01", "2022-12-31", "PTPM_CON") monthly_ptpm <- aggregate_climate(ptpm, "month") head(monthly_ptpm)
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) ptpm <- download_climate_geom(roi, "2022-11-01", "2022-12-31", "PTPM_CON") monthly_ptpm <- aggregate_climate(ptpm, "month") head(monthly_ptpm)
dictionary for climate tags
data(climate_tags)
data(climate_tags)
An object of class list
of length 2.
Dictionary for climate tags
Retrieve departments' DIVIPOLA official names from their DIVIPOLA codes.
code_to_name_dep(department_code)
code_to_name_dep(department_code)
department_code |
character vector with the DIVIPOLA codes of the departments. |
character vector with the DIVIPOLA name of the departments.
dptos <- c("73", "05", "11") code_to_name_dep(dptos)
dptos <- c("73", "05", "11") code_to_name_dep(dptos)
Retrieve municipalities' DIVIPOLA official names from their DIVIPOLA codes.
code_to_name_mun(municipality_code)
code_to_name_mun(municipality_code)
municipality_code |
character vector with the DIVIPOLA codes of the municipalities. |
character vector with the DIVIPOLA name of the municipalities.
mpios <- c("73001", "11001", "05615") code_to_name_mun(mpios)
mpios <- c("73001", "11001", "05615") code_to_name_mun(mpios)
list of datasets description in English and Spanish
data(datasets_list)
data(datasets_list)
An object of class list
of length 2.
List containing both datasets description in English and Spanish
Retrieve DIVIPOLA table including departments and municipalities. DIVIPOLA codification includes individual codes for each department and municipality following the political and administrative division.
divipola_table()
divipola_table()
data.frame
object with DIVIPOLA table.
divipola <- divipola_table()
divipola <- divipola_table()
Download climate data from stations contained in a municipality or department. This data is retrieved from local meteorological stations provided by IDEAM.
download_climate(code, start_date, end_date, tag)
download_climate(code, start_date, end_date, tag)
code |
character with the DIVIPOLA code for the area (2 digits for departments and 5 digits for municipalities). |
start_date |
character with the first date to consult in the format
|
end_date |
character with the last date to consult in the format
|
tag |
character containing climate tag to consult. Please use
|
data.frame
object with observations from the stations in the
area.
ptpm <- download_climate("73148", "2021-11-14", "2021-11-20", "PTPM_CON") head(ptpm)
ptpm <- download_climate("73148", "2021-11-14", "2021-11-20", "PTPM_CON") head(ptpm)
Download climate data from stations contained in a Region of Interest (ROI/geometry). This data is retrieved from local meteorological stations provided by IDEAM.
download_climate_geom(geometry, start_date, end_date, tag)
download_climate_geom(geometry, start_date, end_date, tag)
geometry |
|
start_date |
character with the first date to consult in the format
|
end_date |
character with the last date to consult in the format
|
tag |
character containing climate tag to consult. |
data.frame
object with observations from the stations in the
area.
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) ptpm <- download_climate_geom(roi, "2022-11-14", "2022-11-20", "PTPM_CON") head(ptpm)
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) ptpm <- download_climate_geom(roi, "2022-11-14", "2022-11-20", "PTPM_CON") head(ptpm)
Download climate data from IDEAM stations by individual codes.This data is retrieved from local meteorological stations provided by IDEAM.
download_climate_stations(stations, start_date, end_date, tag)
download_climate_stations(stations, start_date, end_date, tag)
stations |
|
start_date |
character with the first date to consult in the format
|
end_date |
character with the last date to consult in the format
|
tag |
character containing climate tag to consult. |
data.frame
object with observations from the stations in the
area.
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) stations <- stations_in_roi(roi) ptpm <- download_climate_stations( stations, "2022-11-14", "2022-11-20", "PTPM_CON" ) head(ptpm)
lat <- c(4.172817, 4.172817, 4.136050, 4.136050, 4.172817) lon <- c(-74.749121, -74.686169, -74.686169, -74.749121, -74.749121) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) stations <- stations_in_roi(roi) ptpm <- download_climate_stations( stations, "2022-11-14", "2022-11-20", "PTPM_CON" ) head(ptpm)
This function downloads demographic datasets from the National Population and Dwelling Census (CNPV) of 2018.
download_demographic(dataset)
download_demographic(dataset)
dataset |
character with the demographic dataset name. Please use
|
data.frame
object with downloaded data.
house_under_15 <- download_demographic("DANE_CNPVH_2018_1HD") head(house_under_15)
house_under_15 <- download_demographic("DANE_CNPVH_2018_1HD") head(house_under_15)
This function downloads geospatial datasets from the National Geostatistical Framework at different levels of spatial aggregation. These datasets include a summarized version of the National Population and Dwelling Census (CNPV) with demographic and socioeconomic information for each spatial unit.
download_geospatial( spatial_level, simplified = TRUE, include_geom = TRUE, include_cnpv = TRUE )
download_geospatial( spatial_level, simplified = TRUE, include_geom = TRUE, include_cnpv = TRUE )
spatial_level |
character with the spatial level to be consulted:
|
simplified |
logical for indicating if the downloaded spatial data
should be a simplified version of the geometries. Simplified versions are
lighter but less precise, and are only recommended for easier applications
like plots. Default is |
include_geom |
logical for including (or not) the spatial geometry.
Default is |
include_cnpv |
logical for including (or not) CNPV demographic and
socioeconomic information. Default is |
data.frame
object with downloaded data.
departments <- download_geospatial("department") head(departments)
departments <- download_geospatial("department") head(departments)
This function downloads population projections and back projections taken from the National Population and Dwelling Census of 2018 (CNPV), adjusted after COVID-19. Available years are different for each spatial level:
"national"
: 1950 - 2070.
"national"
with sex: 1985 - 2050.
"department"
: 1985 - 2050.
"department"
with sex: 1985 - 2050.
"municipality"
: 1985 - 2035.
"municipality"
with sex: 1985 - 2035.
"municipality"
with sex and ethnic groups: 2018 - 2035.
download_pop_projections( spatial_level, start_year, end_year, include_sex = FALSE, include_ethnic = FALSE )
download_pop_projections( spatial_level, start_year, end_year, include_sex = FALSE, include_ethnic = FALSE )
spatial_level |
character with the spatial level to be consulted.
Can be either |
start_year |
numeric with the start year to be consulted. |
end_year |
numeric with the end year to be consulted. |
include_sex |
logical for including (or not) division by sex. Default
is |
include_ethnic |
logical for including (or not) division by ethnic
group (only available for |
data.frame
object with downloaded data.
pop_proj <- download_pop_projections("national", 2020, 2030) head(pop_proj)
pop_proj <- download_pop_projections("national", 2020, 2030) head(pop_proj)
dictionaries of variables presented in geospatial datasets
data(geospatial_dictionaries)
data(geospatial_dictionaries)
An object of class list
of length 2.
Dictionaries for geospatial datasets in English and Spanish
Retrieve geospatial data dictionaries to understand internal tags and named columns. Dictionaries are available in English and Spanish.
geospatial_dictionary(spatial_level, language = "ES")
geospatial_dictionary(spatial_level, language = "ES")
spatial_level |
character with the spatial level to be consulted:
|
language |
character with the language of the dictionary variables
( |
data.frame
object with geospatial data dictionary.
dict <- geospatial_dictionary("setu", "EN") head(dict)
dict <- geospatial_dictionary("setu", "EN") head(dict)
Retrieve available climate tags to be consulted. The list is only available in Spanish.
get_climate_tags(language = "ES")
get_climate_tags(language = "ES")
language |
character with the language of the tags ( |
data.frame
object with available climate tags.
dict <- get_climate_tags("ES") head(dict)
dict <- get_climate_tags("ES") head(dict)
List all available datasets by name, including group, source, year, level, category and description.
list_datasets(module = "all", language = "ES")
list_datasets(module = "all", language = "ES")
module |
character with module to be consulted ( |
language |
character with the language of dataset details ( |
data.frame
object with the available datasets.
list <- list_datasets("geospatial", "EN") head(list)
list <- list_datasets("geospatial", "EN") head(list)
List available datasets containing user-specified keywords in their descriptions.
look_up(keywords, module = "all", logic = "or", language = "EN")
look_up(keywords, module = "all", logic = "or", language = "EN")
keywords |
character or vector of characters to be look up in the description. |
module |
character with module to be consulted ( |
logic |
A character string specifying the matching logic.
Can be either
|
language |
character with the language of the keywords ( |
data.frame
object with the available datasets containing
information related to the consulted keywords.
found <- look_up(c("sex", "age"), "demographic", "and", "EN") head(found)
found <- look_up(c("sex", "age"), "demographic", "and", "EN") head(found)
This function adds the key information of a demographic dataset to a geospatial dataset based on the spatial aggregation level. Since the smallest level of spatial aggregation present in the demographic datasets is municipality, this function can only merge with geospatial datasets that present municipality or department level.
merge_geo_demographic(demographic_dataset, simplified = TRUE)
merge_geo_demographic(demographic_dataset, simplified = TRUE)
demographic_dataset |
character with the demographic dataset name.
Please use |
simplified |
logical for indicating if the downloaded spatial data
should be a simplified version of the geometries. Simplified versions are
lighter but less precise, and are recommended for easier applications like
plots. Default is |
data.frame
object with the merged data.
merged <- merge_geo_demographic("DANE_CNPVV_2018_9VD", TRUE) head(merged)
merged <- merge_geo_demographic("DANE_CNPVV_2018_9VD", TRUE) head(merged)
Retrieve departments' DIVIPOLA codes from their names.
name_to_code_dep(department_name)
name_to_code_dep(department_name)
department_name |
character vector with the names of the departments. |
character vector with the DIVIPOLA codes of the departments.
dptos <- c("Tolima", "Huila", "Amazonas") name_to_code_dep(dptos)
dptos <- c("Tolima", "Huila", "Amazonas") name_to_code_dep(dptos)
Retrieve municipalities' DIVIPOLA codes from their names. Since there are municipalities with the same names in different departments, the input must include two vectors: one for the departments and one for the municipalities in said departments. If only one department is provided, it will try to match all municipalities in the second vector inside that department. Otherwise, the vectors must be the same length.
name_to_code_mun(department_name, municipality_name)
name_to_code_mun(department_name, municipality_name)
department_name |
character vector with the names of the departments containing the municipalities. |
municipality_name |
character vector with the names of the municipalities. |
character vector with the DIVIPOLA codes of the municipalities.
dptos <- c("Huila", "Antioquia") mpios <- c("Pitalito", "Turbo") name_to_code_mun(dptos, mpios)
dptos <- c("Huila", "Antioquia") mpios <- c("Pitalito", "Turbo") name_to_code_mun(dptos, mpios)
Department names are usually manually input, which leads to multiple errors and lack of standardization. This functions translates department names to their respective official names from DIVIPOLA.
name_to_standard_dep(department_name)
name_to_standard_dep(department_name)
department_name |
character vector with the names to be translated. |
character vector with the DIVIPOLA name of the departments.
dptos <- c("Bogota DC", "San Andres") name_to_standard_dep(dptos)
dptos <- c("Bogota DC", "San Andres") name_to_standard_dep(dptos)
Municipality names are usually manually input, which leads to multiple errors and lack of standardization. This functions translates municipality names to their respective official names from DIVIPOLA.
name_to_standard_mun(department_name, municipality_name)
name_to_standard_mun(department_name, municipality_name)
department_name |
character vector with the names of the departments containing the municipalities. |
municipality_name |
character vector with the names to be translated. |
character vector with the DIVIPOLA name of the municipalities.
dptos <- c("Bogota", "Tolima") mpios <- c("Bogota DC", "CarmendeApicala") name_to_standard_mun(dptos, mpios)
dptos <- c("Bogota", "Tolima") mpios <- c("Bogota DC", "CarmendeApicala") name_to_standard_mun(dptos, mpios)
Download and filter climate stations contained inside a region of interest (ROI).
stations_in_roi(geometry)
stations_in_roi(geometry)
geometry |
|
data.frame
object with the stations contained inside the
consulted geometry.
lat <- c(5.166278, 5.166278, 4.982247, 4.982247, 5.166278) lon <- c(-75.678072, -75.327859, -75.327859, -75.678072, -75.678072) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) stations <- stations_in_roi(roi) head(stations)
lat <- c(5.166278, 5.166278, 4.982247, 4.982247, 5.166278) lon <- c(-75.678072, -75.327859, -75.327859, -75.678072, -75.678072) polygon <- sf::st_polygon(x = list(cbind(lon, lat))) geometry <- sf::st_sfc(polygon) roi <- sf::st_as_sf(geometry) stations <- stations_in_roi(roi) head(stations)