Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.5.8 #206

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cancensus
Type: Package
Title: Access, Retrieve, and Work with Canadian Census Data and Geography
Version: 0.5.7
Version: 0.5.8
Authors@R: c(
person("Jens", "von Bergmann", email = "[email protected]", role = c("aut"), comment = "API creator and maintainer"),
person("Dmitry", "Shkolnik", email = "[email protected]", role = c("aut", "cre"), comment = "Package maintainer, responsible for correspondence"),
Expand All @@ -24,7 +24,7 @@ Imports: digest (>= 0.1),
httr (>= 1.0.0),
jsonlite (>= 1.0),
rlang
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Suggests: knitr,
ggplot2,
leaflet,
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# cancensus 0.5.8

- clarify installing API key and cache path in "getting started" vignette
- fix caching problem with get_statcan_wds_data
- support health region level census data for 2021 via WDS

# cancensus 0.5.7

- fix issue with path names not quoted properly when downoading and unpacking geosuite data
Expand Down
11 changes: 9 additions & 2 deletions R/geographies.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#'
#' @param census_year census year to get the data for, right now only 2021 is supported
#' @param level geographic level to return the data for, valid choices are
#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"
#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA", "HR"
#' @param type type of geographic data, valid choices area "cartographic" or "digital"
#' @param cache_path optional path to cache the data. If the cancensus cache path is set the geographic data gets
#' cached in the "geographies" subdirectory of the cancensus cache path.
Expand All @@ -24,7 +24,7 @@ get_statcan_geographies <- function(census_year,level,type="cartographic",
cache_path = NULL,timeout=1000,
refresh=FALSE,quiet=FALSE) {
valid_census_years <- c("2021")
valid_levels <- c("PR","CD","CMACA","CMA","CA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","POPCTR","FSA")
valid_levels <- c("PR","CD","CMACA","CMA","CA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","POPCTR","FSA","HR")
valid_types <- c("cartographic","digital")
if (!(census_year %in% valid_census_years)) {
stop(paste0("Census year must be one of ",paste0(valid_census_years,collapse = ", "),"."))
Expand All @@ -51,6 +51,13 @@ get_statcan_geographies <- function(census_year,level,type="cartographic",
stop(paste0("Problem, don't know how to get geographic data for level ",level,"."))
}
url <- paste0("https://www12.statcan.gc.ca/census-recensement/",census_year,"/geo/sip-pis/boundary-limites/files-fichiers/l",tolower(level),filler,typeID,"21a_e.zip")
if (level=="HR") {
if (type=="cartographic") {
url <- "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2024001/hrbf-flrs/carto/ArcGIS/HR_000b23a_e.zip?st=wQRRL7PQ"
} else {
url <- "https://www150.statcan.gc.ca/n1/en/pub/82-402-x/2024001/hrbf-flrs/digi/ArcGIS/HR_000a23a_e.zip"
}
}
tmp <- tempfile()
options(timeout = timeout)
utils::download.file(url,tmp,mode="wb",quiet=quiet)
Expand Down
10 changes: 5 additions & 5 deletions R/wds.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' @param census_year census year to get the data for, right now only 2021 is supported
#' @param level geographic level to return the data for, valid choices are
#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"
#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA", "HR"
#' @param version optionally specify a version of the data to download. For example, for FED level data, version 1.3 will
#' access the 2013 represenation order, whereas version 2.0 will access the 2023 representation order. By default the latest
#' available version is accessed.
Expand All @@ -21,7 +21,7 @@
#' @export
get_statcan_wds_metadata <- function(census_year,level,version=NULL,refresh=FALSE){
valid_census_years <- c("2021")
valid_levels <- c("PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","FSA")
valid_levels <- c("PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","FSA","HR")
if (!(census_year %in% valid_census_years)) {
stop(paste0("Census year must be one of ",paste0(valid_census_years,collapse = ", "),"."))
}
Expand Down Expand Up @@ -118,9 +118,9 @@ get_statcan_wds_data <- function(DGUIDs,
httr::accept("text/csv"),
httr::add_headers("Accept-Encoding"="deflate, gzip, br"),
httr::write_disk(wds_data_tempfile,overwrite = TRUE))
}
if (!response$status_code=="200") {
stop(paste0("Invalid request.\n",httr::content(response)))
if (!response$status_code=="200") {
stop(paste0("Invalid request.\n",httr::content(response)))
}
}
census_year <- "2021"
meta_data <- get_statcan_wds_metadata(census_year,level=level,version = version,refresh = refresh)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,18 @@ There are several other jurisdiction where census data is available via R packag

If you wish to cite cancensus:

von Bergmann, J., Aaron Jacobs, Dmitry Shkolnik (2022). cancensus: R package to
access, retrieve, and work with Canadian Census data and geography. v0.5.7.
von Bergmann, J., Aaron Jacobs, Dmitry Shkolnik (2024). cancensus: R package to
access, retrieve, and work with Canadian Census data and geography. v0.5.8.


A BibTeX entry for LaTeX users is
```
@Manual{cancensus,
author = {Jens {von Bergmann} and Dmitry Shkolnik and Aaron Jacobs},
title = {cancensus: R package to access, retrieve, and work with Canadian Census data and geography},
year = {2022},
note = {R package version 0.5.7},
year = {2024},
doi = {10.32614/CRAN.package.cancensus},
note = {R package version 0.5.8},
url = {https://mountainmath.github.io/cancensus/}
}
```
Expand Down
6 changes: 6 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# cancensus 0.5.8

- clarify installing API key and cache path in "getting started" vignette
- fix caching problem with get_statcan_wds_data
- support health region level census data for 2021 via WDS

# cancensus 0.5.7
- fix issue with path names not quoted properly when downoading and unpacking geosuite data
- support versions in WDS data, in paricular for federal electoral districts
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions docs/articles/Making_maps_with_cancensus.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/articles/Taxfiler_Data.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions docs/articles/cancensus.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/data_discovery.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/intersecting_geometries.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/statcan_attribute_files.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/statcan_wds.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ articles:
intersecting_geometries: intersecting_geometries.html
statcan_attribute_files: statcan_attribute_files.html
statcan_wds: statcan_wds.html
last_built: 2024-02-09T21:32Z
last_built: 2024-02-22T18:45Z
urls:
reference: https://mountainmath.github.io/cancensus/reference
article: https://mountainmath.github.io/cancensus/articles
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/CODES_TABLE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/COV_SKYTRAIN_STATIONS.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/add_unique_names_to_region_list.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/as_census_region_list.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/census_vectors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/child_census_vectors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/dataset_attribution.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/explore_census_regions.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/reference/explore_census_vectors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading