diff --git a/DESCRIPTION b/DESCRIPTION index dae0b64b..ae507efb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: cancensus Type: Package Title: Access, Retrieve, and Work with Canadian Census Data and Geography -Version: 0.5.5 +Version: 0.5.6 Authors@R: c( person("Jens", "von Bergmann", email = "jens@mountainmath.ca", role = c("aut"), comment = "API creator and maintainer"), person("Dmitry", "Shkolnik", email = "shkolnikd@gmail.com", role = c("aut", "cre"), comment = "Package maintainer, responsible for correspondence"), @@ -24,15 +24,13 @@ Imports: digest (>= 0.1), httr (>= 1.0.0), jsonlite (>= 1.0), rlang -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Suggests: knitr, ggplot2, leaflet, mapdeck, rmarkdown, readr, - rgdal, - rgeos, scales, sp, sf, diff --git a/NEWS.md b/NEWS.md index 4db26f3b..bd049493 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,10 @@ +# cancensus 0.5.6 + +- fix issue when using named vectors to query data for non-existent geographies, return NULL in this case instead of throwing error +- fix problem with population centre geographic data download +- support newly released Forward Sortation Area geography for statcan geography and WDS functionality +- remove instances of new native R pipe |> with dplyr pipe %>% to preserve compatibility with older R versions + # cancensus 0.5.5 - add functionality for direct access to StatCan census WDS for 2021 diff --git a/R/cancensus.R b/R/cancensus.R index e20ad08a..a049467c 100644 --- a/R/cancensus.R +++ b/R/cancensus.R @@ -268,7 +268,10 @@ get_census <- function (dataset, regions, level=NA, vectors=c(), geo_format = NA to_rename <- setNames(names(result),gsub(":.*","",names(result))) to_rename <- to_rename[names(to_rename)!=as.character(to_rename)] if (length(to_rename)>0) result <- result %>% dplyr::rename(!!!to_rename) - if (!is.null(names(vectors))) result <- result %>% dplyr::rename(!!! vectors) + if (!is.null(names(vectors))) { + to_rename <- vectors[as.character(vectors) %in% names(result)] + if (length(to_rename)>0) result <- result %>% dplyr::rename(!!! to_rename) + } } } diff --git a/R/census_regions.R b/R/census_regions.R index a764b5fa..1c394be7 100644 --- a/R/census_regions.R +++ b/R/census_regions.R @@ -34,7 +34,9 @@ #' @export #' #' @examples +#' \dontrun{ #' list_census_regions('CA16') +#' } list_census_regions <- function(dataset, use_cache = TRUE, quiet = FALSE) { dataset <- translate_dataset(dataset) cache_file <- file.path(tempdir(),paste0(dataset, "_regions.rda")) @@ -200,16 +202,16 @@ add_unique_names_to_region_list <- function(region_list) { dplyr::group_by(.data$name) %>% dplyr::mutate(count=dplyr::n()) %>% dplyr::mutate(Name=dplyr::case_when(.data$count==1 ~ name, - TRUE ~ paste0(.data$name," (",.data$municipal_status,")"))) |> + TRUE ~ paste0(.data$name," (",.data$municipal_status,")"))) %>% dplyr::group_by(.data$Name) %>% dplyr::mutate(count=dplyr::n()) %>% dplyr::mutate(Name=dplyr::case_when(.data$count==1 ~ Name, - TRUE ~ paste0(.data$Name," (",.data$region,")"))) |> - dplyr::select(-.data$count) |> + TRUE ~ paste0(.data$Name," (",.data$region,")"))) %>% + dplyr::select(-.data$count) %>% dplyr::ungroup() if (length(gs)>1) { - r <- r |> + r <- r %>% dplyr::group_by(dplyr::across(dplyr::all_of(gs))) } r diff --git a/R/geographies.R b/R/geographies.R index fe5ce12f..0ab321bf 100644 --- a/R/geographies.R +++ b/R/geographies.R @@ -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" +#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA" #' @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. @@ -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") + valid_levels <- c("PR","CD","CMACA","CMA","CA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","POPCTR","FSA") 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 = ", "),".")) @@ -35,7 +35,7 @@ get_statcan_geographies <- function(census_year,level,type="cartographic", if (!(level %in% valid_levels)) { stop(paste0("Level must be one of ",paste0(valid_levels,collapse = ", "),".")) } - level_map <- c("CMACA"="CMA","CA"="CMA","POPCNTR","PC") + level_map <- c("CMACA"="CMA","CA"="CMA","POPCNTR"="PC","POPCTR"="PC") if (level %in% names(level_map)) level <-level_map[[level]] geo_base_path <- cache_path("geographies") if (!dir.exists(geo_base_path)) dir.create(geo_base_path) @@ -56,6 +56,14 @@ get_statcan_geographies <- function(census_year,level,type="cartographic", utils::download.file(url,tmp,mode="wb",quiet=quiet) options(timeout = old_timeout) utils::unzip(tmp,exdir = exdir) + fs <- dir(exdir,full.names = TRUE) + if (length(fs)==1 && dir.exists(fs)) { + tmp_dir <- file.path(geo_base_path,"XXXX") + file.rename(exdir,tmp_dir) + fs <- dir(tmp_dir,full.names = TRUE) + file.rename(fs,exdir) + unlink(tmp_dir) + } } else { if (!quiet) message("Reading geographic data from local cache.") } diff --git a/R/helpers.R b/R/helpers.R index a46ddd0f..35385b89 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -22,7 +22,10 @@ cache_path <- function(...) { if (nchar(cache_dir)==0) { if (!is.null(getOption("cancensus.cache_path"))) { cache_dir <- getOption("cancensus.cache_path") - } else cache_dir <- tempdir() + } else { + cache_dir <- tempdir() + message(cm_no_cache_path_message) + } } if (!is.character(cache_dir)) { stop("Corrupt 'CM_CACHE_PATH' environment variable or 'cancensus.cache_path' option. Must be a path.", diff --git a/R/user_settings.R b/R/user_settings.R index 3febf2ff..3278a78c 100644 --- a/R/user_settings.R +++ b/R/user_settings.R @@ -43,7 +43,8 @@ set_cancensus_api_key <- function(key, overwrite = FALSE, install = FALSE){ keyconcat <- paste0("CM_API_KEY='", key, "'") # Append API key to .Renviron file write(keyconcat, renv, sep = "\n", append = TRUE) - message('Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CM_API_KEY"). \nTo use now, restart R or run `readRenviron("~/.Renviron")`') + Sys.setenv(CM_API_KEY = key) + message('Your API key has been stored in your .Renviron and can be accessed by Sys.getenv("CM_API_KEY").') } else { message("API key set for duration of session. To install your API key for use across sessions, run this function with `install = TRUE`.") Sys.setenv(CM_API_KEY = key) @@ -65,7 +66,7 @@ set_cancensus_api_key <- function(key, overwrite = FALSE, install = FALSE){ #'\dontrun{ #' set_cancensus_cache_path("~/cancensus_cache") #' -#' # This will set the cache path permanently until ovewritten again +#' # This will set the cache path permanently until overwritten again #' set_cancensus_cache_path("~/cancensus_cache", install = TRUE) #' } set_cancensus_cache_path <- function(cache_path, overwrite = FALSE, install = FALSE){ @@ -93,7 +94,8 @@ set_cancensus_cache_path <- function(cache_path, overwrite = FALSE, install = FA keyconcat <- paste0("CM_CACHE_PATH='", cache_path, "'") # Append cache path .Renviron file write(keyconcat, renv, sep = "\n", append = TRUE) - message('Your cache path has been stored in your .Renviron and can be accessed by Sys.getenv("CM_CACHE_PATH"). \nTo use now, restart R or run readRenviron("~/.Renviron").') + message('Your cache path has been stored in your .Renviron and can be accessed by Sys.getenv("CM_CACHE_PATH").') + Sys.setenv('CM_CACHE_PATH' = cache_path) } else { message("Cache set for duration of session. To permanently add your cache path for use across sessions, run this function with install = TRUE.") Sys.setenv('CM_CACHE_PATH' = cache_path) @@ -138,9 +140,8 @@ show_cancensus_cache_path <- function() { cm_no_cache_path_message <- paste( "Census data is currently stored temporarily.\n\n", "In order to speed up performance, reduce API quota usage, and reduce", - "unnecessary network calls, please set up a persistent cache directory by", - "setting the environment variable CM_CACHE_PATH= '' or ", - "setting options(cancensus.cache_path = '')\n\n", - "You may add this environment varianble to your .Renviron", - "or add this option, together with your API key, to your .Rprofile.\n\n" + "unnecessary network calls, please set up a persistent cache directory via", + "`set_cancensus_cache_path('', install = TRUE)`.\n", + "This will add your cache directory as environment varianble to your .Renviron to be", + "used across sessions and projects.\n\n" ) diff --git a/R/wds.R b/R/wds.R index 7e595504..71ef6510 100644 --- a/R/wds.R +++ b/R/wds.R @@ -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" +#' "PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA" #' @param refresh default is `FALSE` will refresh the temporary cache if `TRUE` #' @return tibble with the metadata #' @@ -18,7 +18,7 @@ #' @export get_statcan_wds_metadata <- function(census_year,level,refresh=FALSE){ valid_census_years <- c("2021") - valid_levels <- c("PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR") + valid_levels <- c("PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR","FSA") if (!(census_year %in% valid_census_years)) { stop(paste0("Census year must be one of ",paste0(valid_census_years,collapse = ", "),".")) } @@ -34,24 +34,24 @@ get_statcan_wds_metadata <- function(census_year,level,refresh=FALSE){ code_lists <- xml2::xml_find_all(d,"//structure:Codelist") meta_data <- lapply(code_lists, \(cl){ - codelist_id <- cl |> xml2::xml_attr("id") - agencyID <- cl |> xml2::xml_attr("agencyID") - codelist_en <- cl |> xml2::xml_find_all("common:Name[@xml:lang='en']") |> xml2::xml_text() - codelist_fr <- cl |> xml2::xml_find_all("common:Name[@xml:lang='fr']") |> xml2::xml_text() - description_en <- cl |> xml2::xml_find_all("common:Name[@xml:lang='en']") |> xml2::xml_text() - description_fr <- cl |> xml2::xml_find_all("common:Name[@xml:lang='fr']") |> xml2::xml_text() - codes <- cl |> xml2::xml_find_all("structure:Code") + codelist_id <- cl %>% xml2::xml_attr("id") + agencyID <- cl %>% xml2::xml_attr("agencyID") + codelist_en <- cl %>% xml2::xml_find_all("common:Name[@xml:lang='en']") %>% xml2::xml_text() + codelist_fr <- cl %>% xml2::xml_find_all("common:Name[@xml:lang='fr']") %>% xml2::xml_text() + description_en <- cl %>% xml2::xml_find_all("common:Name[@xml:lang='en']") %>% xml2::xml_text() + description_fr <- cl %>% xml2::xml_find_all("common:Name[@xml:lang='fr']") %>% xml2::xml_text() + codes <- cl %>% xml2::xml_find_all("structure:Code") dplyr::tibble(`Agency ID`=agencyID, `Codelist ID`=codelist_id, `Codelist en`=codelist_en, `Codelist fr`=codelist_fr, - ID=codes |> xml2::xml_attr("id"), - en=codes |> xml2::xml_find_all("common:Name[@xml:lang='en']") |> xml2::xml_text(), - fr=codes |> xml2::xml_find_all("common:Name[@xml:lang='fr']") |> xml2::xml_text(), - `Parent ID`=codes |> xml2::xml_find_all("structure:Parent/Ref",flatten=FALSE) |> - lapply(\(d)ifelse(is.null(d),NA,xml2::xml_attr(d,"id"))) |> unlist() + ID=codes %>% xml2::xml_attr("id"), + en=codes %>% xml2::xml_find_all("common:Name[@xml:lang='en']") %>% xml2::xml_text(), + fr=codes %>% xml2::xml_find_all("common:Name[@xml:lang='fr']") %>% xml2::xml_text(), + `Parent ID`=codes %>% xml2::xml_find_all("structure:Parent/Ref",flatten=FALSE) %>% + lapply(\(d)ifelse(is.null(d),NA,xml2::xml_attr(d,"id"))) %>% unlist() ) - }) |> + }) %>% dplyr::bind_rows() meta_data } @@ -116,22 +116,22 @@ get_statcan_wds_data <- function(DGUIDs, census_year <- "2021" meta_data <- get_statcan_wds_metadata(census_year,level,refresh = refresh) - levels <- meta_data |> + levels <- meta_data %>% dplyr::filter(.data$`Codelist ID`=="CL_GEO_LEVEL") - meta_geos <- meta_data |> + meta_geos <- meta_data %>% dplyr::filter(.data$`Codelist ID`==paste0("CL_GEO_",level)) - meta_characteristics <- meta_data |> + meta_characteristics <- meta_data %>% dplyr::filter(.data$`Codelist ID`=="CL_CHARACTERISTIC") name_field <- language #paste0(language,"_description") - data <- readr::read_csv(wds_data_tempfile,col_types = readr::cols(.default="c")) |> - dplyr::mutate(dplyr::across(dplyr::matches("OBS_VALUE|TNR_CI_"),as.numeric)) |> - dplyr::left_join(meta_geos |> + data <- readr::read_csv(wds_data_tempfile,col_types = readr::cols(.default="c")) %>% + dplyr::mutate(dplyr::across(dplyr::matches("OBS_VALUE|TNR_CI_"),as.numeric)) %>% + dplyr::left_join(meta_geos %>% dplyr::select(GEO_DESC=.data$ID,GEO_NAME=!!as.name(name_field)), - by="GEO_DESC") |> - dplyr::left_join(meta_characteristics |> + by="GEO_DESC") %>% + dplyr::left_join(meta_characteristics %>% dplyr::select(CHARACTERISTIC=.data$ID,CHARACTERISTIC_NAME=!!as.name(name_field)), by="CHARACTERISTIC") diff --git a/README.md b/README.md index 0187dd36..ff6b9965 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,13 @@ library(cancensus) Alternatively, the latest development version can be installed from Github. ``` -devtools::install_github("mountainmath/cancensus") +remotes::install_github("mountainmath/cancensus") library(cancensus) ``` ### API key -**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `set_cancensus_api_key(', install = TRUE)`. +**cancensus** requires a valid CensusMapper API key to use. You can obtain a free API key by [signing up](https://censusmapper.ca/users/sign_up) for a CensusMapper account. To check your API key, just go to "Edit Profile" (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter `set_cancensus_api_key('', install = TRUE)`. CensusMapper API keys are free and public API quotas are generous; however, due to incremental costs of serving large quantities of data, there are some limits to API usage in place. For most use cases, these API limits should not be an issue. Production uses with large extracts of detailed geographies may run into API quota limits. @@ -45,13 +45,13 @@ For larger quotas, please get in touch with Jens [directly](mailto:jens@censusma ### Local Cache -For performance reasons, and to avoid unnecessarily drawing down API quotas, **cancensus** caches data queries under the hood. By default, **cancensus** caches in R's temporary directory, but this cache is not persistent across sessions. In order to speed up performance, reduce quota usage, and reduce the need for unnecessary network calls, we recommend assigning a persistent local cache using `set_cancensus_cache_path(, install = TRUE)`, this enables more efficient loading and reuse of downloaded data. Users will be prompted with a suggestion to change their default cache location when making API calls if one has not been set yet. +For performance reasons, and to avoid unnecessarily drawing down API quotas, **cancensus** caches data queries under the hood. By default, **cancensus** caches in R's temporary directory, but this cache is not persistent across sessions. In order to speed up performance, reduce quota usage, and reduce the need for unnecessary network calls, we recommend assigning a persistent local cache using `set_cancensus_cache_path('', install = TRUE)`, this enables more efficient loading and reuse of downloaded data. Users will be prompted with a suggestion to change their default cache location when making API calls if one has not been set yet. Starting with version 0.5.2 **cancensus** will automatically check if for data that has been recalled by Statistics Canada and is stored in the local cache via the new data recall API implemented in [CensusMapper](https://censusmapper.ca). Statistics Canada occasionally detects and corrects errors in their census data releases, and **cancensus** will download a list of recalled data at the first invocation of `get_census()` in each session and emit a warning if it detected locally cached data that has been recalled. Removal of the cached recalled data has to be done explicitly by the user via the `remove_recalled_chached_data()` function. If data was cached with **cancensus** versions prior to version 0.5.0 there is insufficient metadata to determine all instances of recalled cached data, but the package will check every time cached data is loaded and can identify recalled data at this point at the latest and issues a warning if recalled data is loaded. ### Currently available datasets -**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, 2016, and 2021. You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2021 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2021 Program which can be viewed on their [website](https://www12.statcan.gc.ca/census-recensement/2021/ref/prodserv/release-diffusion-eng.cfm). +**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, 2016, and 2021. You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2021 Census will be included in CensusMapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2021 Program which can be viewed on their [website](https://www12.statcan.gc.ca/census-recensement/2021/ref/prodserv/release-diffusion-eng.cfm). Thanks to contributions by the Canada Mortgage and Housing Corporation (CMHC), **cancensus** now includes additional Census-linked datasets as open-data releases. These include annual taxfiler data at the census tract level for tax years 2000 through 2018, which includes data on incomes and demographics, as well as specialized crosstabs for Structural type of dwelling by Document type, which details occupancy status for residences. These crosstabs are available for the 2001, 2006, 2011, 2016, and 2021 Census years at all levels starting with census tract. @@ -139,7 +139,7 @@ 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.5. + access, retrieve, and work with Canadian Census data and geography. v0.5.6. A BibTeX entry for LaTeX users is @@ -148,7 +148,7 @@ A BibTeX entry for LaTeX users is 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.5}, + note = {R package version 0.5.6}, url = {https://mountainmath.github.io/cancensus/} } ``` diff --git a/cran-comments.md b/cran-comments.md index 003bf85a..7e5da72b 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,9 @@ +# cancensus 0.5.6 +- fix issue when using named vectors to query data for non-existent geographies, return NULL in this case instead of throwing error +- fix problem with population centre geographic data download +- support newly released Forward Sortation Area geography for statcan geography and WDS functionality +- remove instances of new native R pipe |> with dplyr pipe %>% to preserve compatibility with older R versions + # Update 0.5.5 - add functionality for direct access to StatCan census WDS for 2021 - add functionality to download original StatCan geographies for 2021 diff --git a/docs/404.html b/docs/404.html index af0f1d6f..d7d1da8e 100644 --- a/docs/404.html +++ b/docs/404.html @@ -50,7 +50,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -139,7 +139,7 @@

Page not found (404)

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index edbf629d..a1be5b1e 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -103,7 +103,7 @@

License

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/Dwellings_by_document_type_cross_tabulation.html b/docs/articles/Dwellings_by_document_type_cross_tabulation.html index 21ac4288..09d9b034 100644 --- a/docs/articles/Dwellings_by_document_type_cross_tabulation.html +++ b/docs/articles/Dwellings_by_document_type_cross_tabulation.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -180,10 +180,10 @@

E started with cancensus vignette.

 # Attribution for the dataset to be used in graphs
-attribution <- dataset_attribution("CA16xSD")
+attribution <- dataset_attribution("CA16xSD")
 
 # Select all variables base variables, this gives us total counts by structural type of dwelling
-vars <- list_census_vectors("CA16xSD") %>% 
+vars <- list_census_vectors("CA16xSD") %>% 
   filter(is.na(parent_vector))
 variables <- setNames(vars$vector,vars$label)
 
@@ -213,7 +213,7 @@ 

E dwelling_types <- setdiff(names(variables),"Total dwellings") # Grab the census data and compute shares for each dwelling type -census_data <- get_census("CA16xSD",regions=list(CSD="3520005"), vectors = variables, quiet = TRUE) %>% +census_data <- get_census("CA16xSD",regions=list(CSD="3520005"), vectors = variables, quiet = TRUE) %>% pivot_longer(cols = all_of(dwelling_types)) %>% mutate(share=value/`Total dwellings`)

To visualize what this looks like on a bar chart:

@@ -228,7 +228,7 @@

E

As with regular Census data, all data can be retrieved as spatial data. Sometimes it’s easier to use the CensusMapper API interface to search for and select the variables we are interested in. The -explore_census_vectors() function opens a browser with the +explore_census_vectors() function opens a browser with the variable selection tool, we determine that “v_CA16xSD_1” and “v_CA16xSD_28” are the variables enumerating all dwellings and all unoccupied dwellings, respectively.

@@ -237,7 +237,7 @@

E vars <- c(Total="v_CA16xSD_1", Unoccupied="v_CA16xSD_28") # Retrieve data with attached geography -census_data <- get_census("CA16xSD",regions=list(CSD="3520005"), level="CT", quiet = TRUE, geo_format = "sf", +census_data <- get_census("CA16xSD",regions=list(CSD="3520005"), level="CT", quiet = TRUE, geo_format = "sf", vectors = vars,use_cache = FALSE) %>% mutate(share=Unoccupied/Total) @@ -270,7 +270,7 @@

E

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/Making_maps_with_cancensus.html b/docs/articles/Making_maps_with_cancensus.html index 50aa4c6e..06117f31 100644 --- a/docs/articles/Making_maps_with_cancensus.html +++ b/docs/articles/Making_maps_with_cancensus.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -114,10 +114,10 @@ - + -
+
@@ -228,8 +228,8 @@

Interactive maps with leafletleaflet(toronto) %>% addProviderTiles(providers$CartoDB.Positron) %>% addPolygons()

-
-

Adding colour ramps and additional interactivity takes a little bit +

+

Adding colour ramps and additional interactivity takes a little bit more work but is still pretty easy to implement. Following this example we can specify the colour ramp to match our needs.

@@ -242,8 +242,8 @@ 

Interactive maps with leaflet= 1, opacity = 1, fillOpacity = 0.65)

-
- +
+
@@ -264,7 +264,7 @@

Interactive maps with leaflet

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/Making_maps_with_cancensus_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/Making_maps_with_cancensus_files/figure-html/unnamed-chunk-4-1.png index c9afb25a..0667972c 100644 Binary files a/docs/articles/Making_maps_with_cancensus_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/Making_maps_with_cancensus_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.5.4/htmlwidgets.js b/docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.6.2/htmlwidgets.js similarity index 96% rename from docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.5.4/htmlwidgets.js rename to docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.6.2/htmlwidgets.js index da8b2367..1067d029 100644 --- a/docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.5.4/htmlwidgets.js +++ b/docs/articles/Making_maps_with_cancensus_files/htmlwidgets-1.6.2/htmlwidgets.js @@ -287,20 +287,18 @@ document.body.style.height = "100%"; document.documentElement.style.width = "100%"; document.documentElement.style.height = "100%"; - if (cel) { - cel.style.position = "absolute"; - var pad = unpackPadding(sizing.padding); - cel.style.top = pad.top + "px"; - cel.style.right = pad.right + "px"; - cel.style.bottom = pad.bottom + "px"; - cel.style.left = pad.left + "px"; - el.style.width = "100%"; - el.style.height = "100%"; - } + cel.style.position = "absolute"; + var pad = unpackPadding(sizing.padding); + cel.style.top = pad.top + "px"; + cel.style.right = pad.right + "px"; + cel.style.bottom = pad.bottom + "px"; + cel.style.left = pad.left + "px"; + el.style.width = "100%"; + el.style.height = "100%"; return { - getWidth: function() { return cel.offsetWidth; }, - getHeight: function() { return cel.offsetHeight; } + getWidth: function() { return cel.getBoundingClientRect().width; }, + getHeight: function() { return cel.getBoundingClientRect().height; } }; } else { @@ -308,8 +306,8 @@ el.style.height = px(sizing.height); return { - getWidth: function() { return el.offsetWidth; }, - getHeight: function() { return el.offsetHeight; } + getWidth: function() { return cel.getBoundingClientRect().width; }, + getHeight: function() { return cel.getBoundingClientRect().height; } }; } } @@ -533,8 +531,8 @@ elementData(el, "initialized", true); if (bindingDef.initialize) { - var result = bindingDef.initialize(el, el.offsetWidth, - el.offsetHeight); + var rect = el.getBoundingClientRect(); + var result = bindingDef.initialize(el, rect.width, rect.height); elementData(el, "init_result", result); } } @@ -576,29 +574,30 @@ forEach(matches, function(el) { var sizeObj = initSizing(el, binding); + var getSize = function(el) { + if (sizeObj) { + return {w: sizeObj.getWidth(), h: sizeObj.getHeight()} + } else { + var rect = el.getBoundingClientRect(); + return {w: rect.width, h: rect.height} + } + }; + if (hasClass(el, "html-widget-static-bound")) return; el.className = el.className + " html-widget-static-bound"; var initResult; if (binding.initialize) { - initResult = binding.initialize(el, - sizeObj ? sizeObj.getWidth() : el.offsetWidth, - sizeObj ? sizeObj.getHeight() : el.offsetHeight - ); + var size = getSize(el); + initResult = binding.initialize(el, size.w, size.h); elementData(el, "init_result", initResult); } if (binding.resize) { - var lastSize = { - w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, - h: sizeObj ? sizeObj.getHeight() : el.offsetHeight - }; + var lastSize = getSize(el); var resizeHandler = function(e) { - var size = { - w: sizeObj ? sizeObj.getWidth() : el.offsetWidth, - h: sizeObj ? sizeObj.getHeight() : el.offsetHeight - }; + var size = getSize(el); if (size.w === 0 && size.h === 0) return; if (size.w === lastSize.w && size.h === lastSize.h) @@ -900,4 +899,3 @@ return result; } })(); - diff --git a/docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.1.1/leaflet.js b/docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.2.0/leaflet.js similarity index 99% rename from docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.1.1/leaflet.js rename to docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.2.0/leaflet.js index 1eafcbe0..c8e7e5e0 100644 --- a/docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.1.1/leaflet.js +++ b/docs/articles/Making_maps_with_cancensus_files/leaflet-binding-2.2.0/leaflet.js @@ -593,8 +593,20 @@ function preventUnintendedZoomOnScroll(map) { }); (0, _jquery2["default"])(document).on("mousemove", "*", function (e) { // Did the mouse really move? - if (lastScreen.x !== null && e.screenX !== lastScreen.x || e.screenY !== lastScreen.y) { - // It really moved. Enable zooming. + if (map.options.scrollWheelZoom) { + if (lastScreen.x !== null && e.screenX !== lastScreen.x || e.screenY !== lastScreen.y) { + // It really moved. Enable zooming. + map.scrollWheelZoom.enable(); + lastScreen = { + x: null, + y: null + }; + } + } + }); + (0, _jquery2["default"])(document).on("mousedown", ".leaflet", function (e) { + // Clicking always enables zooming. + if (map.options.scrollWheelZoom) { map.scrollWheelZoom.enable(); lastScreen = { x: null, @@ -602,14 +614,6 @@ function preventUnintendedZoomOnScroll(map) { }; } }); - (0, _jquery2["default"])(document).on("mousedown", ".leaflet", function (e) { - // Clicking always enables zooming. - map.scrollWheelZoom.enable(); - lastScreen = { - x: null, - y: null - }; - }); } _htmlwidgets2["default"].widget({ diff --git a/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.9.0/leaflet-providers_1.9.0.js b/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.13.0/leaflet-providers_1.13.0.js similarity index 64% rename from docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.9.0/leaflet-providers_1.9.0.js rename to docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.13.0/leaflet-providers_1.13.0.js index e842c82d..e9986a97 100644 --- a/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.9.0/leaflet-providers_1.9.0.js +++ b/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-1.13.0/leaflet-providers_1.13.0.js @@ -77,7 +77,7 @@ L.TileLayer.Provider.providers = { OpenStreetMap: { - url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', options: { maxZoom: 19, attribution: @@ -86,27 +86,27 @@ variants: { Mapnik: {}, DE: { - url: '//{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', options: { maxZoom: 18 } }, CH: { - url: '//tile.osm.ch/switzerland/{z}/{x}/{y}.png', + url: 'https://tile.osm.ch/switzerland/{z}/{x}/{y}.png', options: { maxZoom: 18, bounds: [[45, 5], [48, 11]] } }, France: { - url: '//{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', options: { maxZoom: 20, - attribution: '© Openstreetmap France | {attribution.OpenStreetMap}' + attribution: '© OpenStreetMap France | {attribution.OpenStreetMap}' } }, HOT: { - url: '//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', options: { attribution: '{attribution.OpenStreetMap}, ' + @@ -115,7 +115,7 @@ } }, BZH: { - url: '//tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', + url: 'https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', options: { attribution: '{attribution.OpenStreetMap}, Tiles courtesy of Breton OpenStreetMap Team', bounds: [[46.2, -5.5], [50, 0.7]] @@ -124,16 +124,16 @@ } }, OpenSeaMap: { - url: '//tiles.openseamap.org/seamark/{z}/{x}/{y}.png', + url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', options: { attribution: 'Map data: © OpenSeaMap contributors' } }, - OpenPtMap: { - url: 'http://openptmap.org/tiles/{z}/{x}/{y}.png', + OPNVKarte: { + url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png', options: { - maxZoom: 17, - attribution: 'Map data: © OpenPtMap contributors' + maxZoom: 18, + attribution: 'Map memomaps.de CC-BY-SA, map data {attribution.OpenStreetMap}' } }, OpenTopoMap: { @@ -158,12 +158,33 @@ } }, SafeCast: { - url: '//s3.amazonaws.com/te512.safecast.org/{z}/{x}/{y}.png', + url: 'https://s3.amazonaws.com/te512.safecast.org/{z}/{x}/{y}.png', options: { maxZoom: 16, attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © SafeCast (CC-BY-SA)' } }, + Stadia: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png', + options: { + maxZoom: 20, + attribution: '© Stadia Maps, © OpenMapTiles © OpenStreetMap contributors' + }, + variants: { + AlidadeSmooth: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png' + }, + AlidadeSmoothDark: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png' + }, + OSMBright: { + url: 'https://tiles.stadiamaps.com/tiles/osm_bright/{z}/{x}/{y}{r}.png' + }, + Outdoors: { + url: 'https://tiles.stadiamaps.com/tiles/outdoors/{z}/{x}/{y}{r}.png' + } + } + }, Thunderforest: { url: 'https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}', options: { @@ -197,60 +218,17 @@ Neighbourhood: 'neighbourhood' } }, - OpenMapSurfer: { - url: 'https://maps.heigit.org/openmapsurfer/tiles/{variant}/webmercator/{z}/{x}/{y}.png', + CyclOSM: { + url: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', options: { - maxZoom: 19, - variant: 'roads', - attribution: 'Imagery from GIScience Research Group @ University of Heidelberg | Map data ' - }, - variants: { - Roads: { - options: { - variant: 'roads', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - Hybrid: { - options: { - variant: 'hybrid', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - AdminBounds: { - options: { - variant: 'adminb', - maxZoom: 18, - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - }, - ContourLines: { - options: { - variant: 'asterc', - maxZoom: 18, - minZoom: 13, - attribution: '{attribution.OpenMapSurfer} ASTER GDEM' - } - }, - Hillshade: { - options: { - variant: 'asterh', - maxZoom: 18, - attribution: '{attribution.OpenMapSurfer} ASTER GDEM, SRTM' - } - }, - ElementsAtRisk: { - options: { - variant: 'elements_at_risk', - attribution: '{attribution.OpenMapSurfer}{attribution.OpenStreetMap}' - } - } + maxZoom: 20, + attribution: 'CyclOSM | Map data: {attribution.OpenStreetMap}' } }, Hydda: { - url: '//{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', + url: 'https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', options: { - maxZoom: 18, + maxZoom: 20, variant: 'full', attribution: 'Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}' }, @@ -260,20 +238,75 @@ RoadsAndLabels: 'roads_and_labels' } }, + Jawg: { + url: 'https://{s}.tile.jawg.io/{variant}/{z}/{x}/{y}{r}.png?access-token={accessToken}', + options: { + attribution: + '© JawgMaps ' + + '{attribution.OpenStreetMap}', + minZoom: 0, + maxZoom: 22, + subdomains: 'abcd', + variant: 'jawg-terrain', + // Get your own Jawg access token here : https://www.jawg.io/lab/ + // NB : this is a demonstration key that comes with no guarantee + accessToken: '', + }, + variants: { + Streets: 'jawg-streets', + Terrain: 'jawg-terrain', + Sunny: 'jawg-sunny', + Dark: 'jawg-dark', + Light: 'jawg-light', + Matrix: 'jawg-matrix' + } + }, MapBox: { - url: 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}{r}.png?access_token={accessToken}', + url: 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}{r}?access_token={accessToken}', options: { attribution: - '© Mapbox ' + + '© Mapbox ' + '{attribution.OpenStreetMap} ' + 'Improve this map', - subdomains: 'abcd', - id: 'mapbox.streets', + tileSize: 512, + maxZoom: 18, + zoomOffset: -1, + id: 'mapbox/streets-v11', accessToken: '', } }, + MapTiler: { + url: 'https://api.maptiler.com/maps/{variant}/{z}/{x}/{y}{r}.{ext}?key={key}', + options: { + attribution: + '© MapTiler © OpenStreetMap contributors', + variant: 'streets', + ext: 'png', + key: '', + tileSize: 512, + zoomOffset: -1, + minZoom: 0, + maxZoom: 21 + }, + variants: { + Streets: 'streets', + Basic: 'basic', + Bright: 'bright', + Pastel: 'pastel', + Positron: 'positron', + Hybrid: { + options: { + variant: 'hybrid', + ext: 'jpg' + } + }, + Toner: 'toner', + Topo: 'topo', + Voyager: 'voyager' + } + }, Stamen: { - url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}{r}.{ext}', + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}{r}.{ext}', options: { attribution: 'Map tiles by Stamen Design, ' + @@ -293,7 +326,7 @@ TonerLabels: 'toner-labels', TonerLite: 'toner-lite', Watercolor: { - url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', options: { variant: 'watercolor', ext: 'jpg', @@ -323,7 +356,7 @@ } }, TopOSMRelief: { - url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', options: { variant: 'toposm-color-relief', ext: 'jpg', @@ -358,7 +391,7 @@ } }, Esri: { - url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', + url: 'https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', options: { variant: 'World_Street_Map', attribution: 'Tiles © Esri' @@ -446,7 +479,7 @@ options: { maxZoom: 19, attribution: 'Map data © OpenWeatherMap', - apiKey:'', + apiKey: '', opacity: 0.5 }, variants: { @@ -466,7 +499,7 @@ HERE: { /* * HERE maps, formerly Nokia maps. - * These basemaps are free, but you need an API key. Please sign up at + * These basemaps are free, but you need an api id and app key. Please sign up at * https://developer.here.com/plans */ url: @@ -582,12 +615,120 @@ } } }, + HEREv3: { + /* + * HERE maps API Version 3. + * These basemaps are free, but you need an API key. Please sign up at + * https://developer.here.com/plans + * Version 3 deprecates the app_id and app_code access in favor of apiKey + * + * Supported access methods as of 2019/12/21: + * @see https://developer.here.com/faqs#access-control-1--how-do-you-control-access-to-here-location-services + */ + url: + 'https://{s}.{base}.maps.ls.hereapi.com/maptile/2.1/' + + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + + 'apiKey={apiKey}&lg={language}', + options: { + attribution: + 'Map © 1987-' + new Date().getFullYear() + ' HERE', + subdomains: '1234', + mapID: 'newest', + apiKey: '', + base: 'base', + variant: 'normal.day', + maxZoom: 20, + type: 'maptile', + language: 'eng', + format: 'png8', + size: '256' + }, + variants: { + normalDay: 'normal.day', + normalDayCustom: 'normal.day.custom', + normalDayGrey: 'normal.day.grey', + normalDayMobile: 'normal.day.mobile', + normalDayGreyMobile: 'normal.day.grey.mobile', + normalDayTransit: 'normal.day.transit', + normalDayTransitMobile: 'normal.day.transit.mobile', + normalNight: 'normal.night', + normalNightMobile: 'normal.night.mobile', + normalNightGrey: 'normal.night.grey', + normalNightGreyMobile: 'normal.night.grey.mobile', + normalNightTransit: 'normal.night.transit', + normalNightTransitMobile: 'normal.night.transit.mobile', + reducedDay: 'reduced.day', + reducedNight: 'reduced.night', + basicMap: { + options: { + type: 'basetile' + } + }, + mapLabels: { + options: { + type: 'labeltile', + format: 'png' + } + }, + trafficFlow: { + options: { + base: 'traffic', + type: 'flowtile' + } + }, + carnavDayGrey: 'carnav.day.grey', + hybridDay: { + options: { + base: 'aerial', + variant: 'hybrid.day' + } + }, + hybridDayMobile: { + options: { + base: 'aerial', + variant: 'hybrid.day.mobile' + } + }, + hybridDayTransit: { + options: { + base: 'aerial', + variant: 'hybrid.day.transit' + } + }, + hybridDayGrey: { + options: { + base: 'aerial', + variant: 'hybrid.grey.day' + } + }, + pedestrianDay: 'pedestrian.day', + pedestrianNight: 'pedestrian.night', + satelliteDay: { + options: { + base: 'aerial', + variant: 'satellite.day' + } + }, + terrainDay: { + options: { + base: 'aerial', + variant: 'terrain.day' + } + }, + terrainDayMobile: { + options: { + base: 'aerial', + variant: 'terrain.day.mobile' + } + } + } + }, FreeMapSK: { - url: 'http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', + url: 'https://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', options: { minZoom: 8, maxZoom: 16, - subdomains: '1234', + subdomains: 'abcd', bounds: [[47.204642, 15.996093], [49.830896, 22.576904]], attribution: '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk' @@ -605,7 +746,7 @@ options: { attribution: '{attribution.OpenStreetMap} © CARTO', subdomains: 'abcd', - maxZoom: 19, + maxZoom: 20, variant: 'light_all' }, variants: { @@ -639,11 +780,12 @@ } }, BasemapAT: { - url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}', + url: 'https://maps{s}.wien.gv.at/basemap/{variant}/{type}/google3857/{z}/{y}/{x}.{format}', options: { maxZoom: 19, attribution: 'Datenquelle: basemap.at', subdomains: ['', '1', '2', '3', '4'], + type: 'normal', format: 'png', bounds: [[46.358770, 8.782379], [49.037872, 17.189532]], variant: 'geolandbasemap' @@ -657,6 +799,20 @@ }, grau: 'bmapgrau', overlay: 'bmapoverlay', + terrain: { + options: { + variant: 'bmapgelaende', + type: 'grau', + format: 'jpeg' + } + }, + surface: { + options: { + variant: 'bmapoberflaeche', + type: 'grau', + format: 'jpeg' + } + }, highdpi: { options: { variant: 'bmaphidpi', @@ -673,19 +829,19 @@ } }, nlmaps: { - url: '//geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png', + url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png', options: { minZoom: 6, maxZoom: 19, bounds: [[50.5, 3.25], [54, 7.6]], - attribution: 'Kaartgegevens © Kadaster' + attribution: 'Kaartgegevens © Kadaster' }, variants: { 'standaard': 'brtachtergrondkaart', 'pastel': 'brtachtergrondkaartpastel', 'grijs': 'brtachtergrondkaartgrijs', 'luchtfoto': { - 'url': '//geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/1.0.0/2016_ortho25/EPSG:3857/{z}/{x}/{y}.png', + 'url': 'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_ortho25/EPSG:3857/{z}/{x}/{y}.jpeg', } } }, @@ -721,7 +877,7 @@ }, ModisTerraSnowCover: { options: { - variant: 'MODIS_Terra_Snow_Cover', + variant: 'MODIS_Terra_NDSI_Snow_Cover', format: 'png', maxZoom: 8, opacity: 0.75 @@ -754,7 +910,7 @@ // z0-9 - 1:1m // z10-11 - quarter inch (1:253440) // z12-18 - one inch (1:63360) - url: '//nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', + url: 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', options: { attribution: 'National Library of Scotland Historic Maps', bounds: [[49.6, -12], [61.7, 3]], @@ -767,7 +923,7 @@ // Justice Map (http://www.justicemap.org/) // Visualize race and income data for your community, county and country. // Includes tools for data journalists, bloggers and community activists. - url: 'http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png', + url: 'https://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png', options: { attribution: 'Justice Map', // one of 'county', 'tract', 'block' @@ -787,14 +943,6 @@ plurality: 'plural' } }, - Wikimedia: { - url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png', - options: { - attribution: 'Wikimedia', - minZoom: 1, - maxZoom: 19 - } - }, GeoportailFrance: { url: 'https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER={variant}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}', options: { @@ -805,31 +953,30 @@ // Get your own geoportail apikey here : http://professionnels.ign.fr/ign/contrats/ // NB : 'choisirgeoportail' is a demonstration key that comes with no guarantee apikey: 'choisirgeoportail', - format: 'image/jpeg', - style : 'normal', - variant: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD' + format: 'image/png', + style: 'normal', + variant: 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2' }, variants: { + plan: 'GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2', parcels: { - options : { - variant: 'CADASTRALPARCELS.PARCELS', - maxZoom: 20, - style : 'bdparcellaire', - format: 'image/png' + options: { + variant: 'CADASTRALPARCELS.PARCELLAIRE_EXPRESS', + style: 'PCI vecteur', + maxZoom: 20 } }, - ignMaps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS', - maps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD', orthos: { options: { maxZoom: 19, + format: 'image/jpeg', variant: 'ORTHOIMAGERY.ORTHOPHOTOS' } } } }, OneMapSG: { - url: '//maps-{s}.onemap.sg/v3/{variant}/{z}/{x}/{y}.png', + url: 'https://maps-{s}.onemap.sg/v3/{variant}/{z}/{x}/{y}.png', options: { variant: 'Default', minZoom: 11, @@ -844,6 +991,104 @@ Grey: 'Grey', LandLot: 'LandLot' } + }, + USGS: { + url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}', + options: { + maxZoom: 20, + attribution: 'Tiles courtesy of the U.S. Geological Survey' + }, + variants: { + USTopo: {}, + USImagery: { + url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}' + }, + USImageryTopo: { + url: 'https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/{z}/{y}/{x}' + } + } + }, + WaymarkedTrails: { + url: 'https://tile.waymarkedtrails.org/{variant}/{z}/{x}/{y}.png', + options: { + maxZoom: 18, + attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © waymarkedtrails.org (CC-BY-SA)' + }, + variants: { + hiking: 'hiking', + cycling: 'cycling', + mtb: 'mtb', + slopes: 'slopes', + riding: 'riding', + skating: 'skating' + } + }, + OpenAIP: { + url: 'https://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.{ext}', + options: { + attribution: 'openAIP Data (CC-BY-NC-SA)', + ext: 'png', + minZoom: 4, + maxZoom: 14, + tms: true, + detectRetina: true, + subdomains: '12' + } + }, + OpenSnowMap: { + url: 'https://tiles.opensnowmap.org/{variant}/{z}/{x}/{y}.png', + options: { + minZoom: 9, + maxZoom: 18, + attribution: 'Map data: {attribution.OpenStreetMap} & ODbL, © www.opensnowmap.org CC-BY-SA' + }, + variants: { + pistes: 'pistes', + } + }, + AzureMaps: { + url: + 'https://atlas.microsoft.com/map/tile?api-version={apiVersion}'+ + '&tilesetId={variant}&x={x}&y={y}&zoom={z}&language={language}'+ + '&subscription-key={subscriptionKey}', + options: { + attribution: 'See https://docs.microsoft.com/en-US/rest/api/maps/renderv2/getmaptilepreview for details.', + apiVersion: '2.0', + variant: 'microsoft.imagery', + subscriptionKey: '', + language: 'en-US', + }, + variants: { + MicrosoftImagery: 'microsoft.imagery', + MicrosoftBaseDarkGrey: 'microsoft.base.darkgrey', + MicrosoftBaseRoad: 'microsoft.base.road', + MicrosoftBaseHybridRoad: 'microsoft.base.hybrid.road', + MicrosoftTerraMain: 'microsoft.terra.main', + MicrosoftWeatherInfraredMain: { + url: + 'https://atlas.microsoft.com/map/tile?api-version={apiVersion}'+ + '&tilesetId={variant}&x={x}&y={y}&zoom={z}'+ + '&timeStamp={timeStamp}&language={language}' + + '&subscription-key={subscriptionKey}', + options: { + timeStamp: '2021-05-08T09:03:00Z', + attribution: 'See https://docs.microsoft.com/en-US/rest/api/maps/renderv2/getmaptilepreview#uri-parameters for details.', + variant: 'microsoft.weather.infrared.main', + }, + }, + MicrosoftWeatherRadarMain: { + url: + 'https://atlas.microsoft.com/map/tile?api-version={apiVersion}'+ + '&tilesetId={variant}&x={x}&y={y}&zoom={z}'+ + '&timeStamp={timeStamp}&language={language}' + + '&subscription-key={subscriptionKey}', + options: { + timeStamp: '2021-05-08T09:03:00Z', + attribution: 'See https://docs.microsoft.com/en-US/rest/api/maps/renderv2/getmaptilepreview#uri-parameters for details.', + variant: 'microsoft.weather.radar.main', + }, + } + }, } }; diff --git a/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-plugin-2.1.1/leaflet-providers-plugin.js b/docs/articles/Making_maps_with_cancensus_files/leaflet-providers-plugin-2.2.0/leaflet-providers-plugin.js similarity index 100% rename from docs/articles/Making_maps_with_cancensus_files/leaflet-providers-plugin-2.1.1/leaflet-providers-plugin.js rename to docs/articles/Making_maps_with_cancensus_files/leaflet-providers-plugin-2.2.0/leaflet-providers-plugin.js diff --git a/docs/articles/Making_maps_with_cancensus_files/leafletfix-1.0.0/leafletfix.css b/docs/articles/Making_maps_with_cancensus_files/leafletfix-1.0.0/leafletfix.css index 3ae60ffa..466d8681 100644 --- a/docs/articles/Making_maps_with_cancensus_files/leafletfix-1.0.0/leafletfix.css +++ b/docs/articles/Making_maps_with_cancensus_files/leafletfix-1.0.0/leafletfix.css @@ -5,7 +5,7 @@ img.leaflet-tile { border-radius: 0; border: none; } -.info { +.leaflet .info { padding: 6px 8px; font: 14px/16px Arial, Helvetica, sans-serif; background: white; @@ -13,17 +13,17 @@ img.leaflet-tile { box-shadow: 0 0 15px rgba(0,0,0,0.2); border-radius: 5px; } -.legend { +.leaflet .legend { line-height: 18px; color: #555; } -.legend svg text { +.leaflet .legend svg text { fill: #555; } -.legend svg line { +.leaflet .legend svg line { stroke: #555; } -.legend i { +.leaflet .legend i { width: 18px; height: 18px; margin-right: 4px; diff --git a/docs/articles/Taxfiler_Data.html b/docs/articles/Taxfiler_Data.html index 5bf003a6..b2c6f5b4 100644 --- a/docs/articles/Taxfiler_Data.html +++ b/docs/articles/Taxfiler_Data.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -174,58 +174,56 @@

library(ggplot2) library(sf)

To see all available T1FF datasets and their reference codes we can -use list_census_datasets().

+use list_census_datasets().

-list_census_datasets() %>% 
+list_census_datasets() %>% 
   filter(grepl("taxfiler",description))
 #> # A tibble: 19 × 6
-#>    dataset description             geo_dataset attribution       refer…¹ refer…²
-#>    <chr>   <chr>                   <chr>       <chr>             <chr>   <chr>  
-#>  1 TX2000  2000 T1FF taxfiler data CA1996      StatCan 2000 T1F… 72-212… https:…
-#>  2 TX2001  2001 T1FF taxfiler data CA01        StatCan 2001 T1F… 72-212… https:…
-#>  3 TX2002  2002 T1FF taxfiler data CA01        StatCan 2002 T1F… 72-212… https:…
-#>  4 TX2003  2003 T1FF taxfiler data CA01        StatCan 2003 T1F… 72-212… https:…
-#>  5 TX2004  2004 T1FF taxfiler data CA01        StatCan 2004 T1F… 72-212… https:…
-#>  6 TX2005  2005 T1FF taxfiler data CA01        StatCan 2005 T1F… 72-212… https:…
-#>  7 TX2006  2006 T1FF taxfiler data CA06        StatCan 2006 T1F… 72-212… https:…
-#>  8 TX2007  2007 T1FF taxfiler data CA06        StatCan 2007 T1F… 72-212… https:…
-#>  9 TX2008  2008 T1FF taxfiler data CA06        StatCan 2008 T1F… 72-212… https:…
-#> 10 TX2009  2009 T1FF taxfiler data CA06        StatCan 2009 T1F… 72-212… https:…
-#> 11 TX2010  2010 T1FF taxfiler data CA06        StatCan 2010 T1F… 72-212… https:…
-#> 12 TX2011  2011 T1FF taxfiler data CA06        StatCan 2011 T1F… 72-212… https:…
-#> 13 TX2012  2012 T1FF taxfiler data CA11        StatCan 2012 T1F… 72-212… https:…
-#> 14 TX2013  2013 T1FF taxfiler data CA11        StatCan 2013 T1F… 72-212… https:…
-#> 15 TX2014  2014 T1FF taxfiler data CA11        StatCan 2014 T1F… 72-212… https:…
-#> 16 TX2015  2015 T1FF taxfiler data CA11        StatCan 2015 T1F… 72-212… https:…
-#> 17 TX2016  2016 T1FF taxfiler data CA16        StatCan 2016 T1F… 72-212… https:…
-#> 18 TX2017  2017 T1FF taxfiler data CA16        StatCan 2017 T1F… 72-212… https:…
-#> 19 TX2018  2018 T1FF taxfiler data CA16        StatCan 2018 T1F… 72-212… https:…
-#> # … with abbreviated variable names ¹​reference, ²​reference_url
+#> dataset description geo_dataset attribution reference reference_url +#> <chr> <chr> <chr> <chr> <chr> <chr> +#> 1 TX2000 2000 T1FF taxfiler d… CA1996 StatCan 20… 72-212-X https://www1… +#> 2 TX2001 2001 T1FF taxfiler d… CA01 StatCan 20… 72-212-X https://www1… +#> 3 TX2002 2002 T1FF taxfiler d… CA01 StatCan 20… 72-212-X https://www1… +#> 4 TX2003 2003 T1FF taxfiler d… CA01 StatCan 20… 72-212-X https://www1… +#> 5 TX2004 2004 T1FF taxfiler d… CA01 StatCan 20… 72-212-X https://www1… +#> 6 TX2005 2005 T1FF taxfiler d… CA01 StatCan 20… 72-212-X https://www1… +#> 7 TX2006 2006 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 8 TX2007 2007 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 9 TX2008 2008 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 10 TX2009 2009 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 11 TX2010 2010 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 12 TX2011 2011 T1FF taxfiler d… CA06 StatCan 20… 72-212-X https://www1… +#> 13 TX2012 2012 T1FF taxfiler d… CA11 StatCan 20… 72-212-X https://www1… +#> 14 TX2013 2013 T1FF taxfiler d… CA11 StatCan 20… 72-212-X https://www1… +#> 15 TX2014 2014 T1FF taxfiler d… CA11 StatCan 20… 72-212-X https://www1… +#> 16 TX2015 2015 T1FF taxfiler d… CA11 StatCan 20… 72-212-X https://www1… +#> 17 TX2016 2016 T1FF taxfiler d… CA16 StatCan 20… 72-212-X https://www1… +#> 18 TX2017 2017 T1FF taxfiler d… CA16 StatCan 20… 72-212-X https://www1… +#> 19 TX2018 2018 T1FF taxfiler d… CA16 StatCan 20… 72-212-X https://www1…

And, as an example, available data vectors for one such T1FF dataset.

-list_census_vectors('TX2017')
+list_census_vectors('TX2017')
 #> # A tibble: 818 × 7
-#>    vector      type  label           units              parent…¹ aggre…² details
-#>    <chr>       <fct> <chr>           <fct>              <chr>    <chr>   <chr>  
-#>  1 v_TX2017_1  Total Taxfilers - #   Number             NA       Additi… Tax da…
-#>  2 v_TX2017_3  Total % 0-24          Percentage (0-100) v_TX201… Averag… Tax da…
-#>  3 v_TX2017_4  Total % 25-44         Percentage (0-100) v_TX201… Averag… Tax da…
-#>  4 v_TX2017_5  Total % 45-64         Percentage (0-100) v_TX201… Averag… Tax da…
-#>  5 v_TX2017_6  Total % 65+           Percentage (0-100) v_TX201… Averag… Tax da…
-#>  6 v_TX2017_7  Total Average - Age   Ratio              v_TX201… Averag… Tax da…
-#>  7 v_TX2017_8  Total % female        Percentage (0-100) v_TX201… Averag… Tax da…
-#>  8 v_TX2017_9  Total % married       Percentage (0-100) v_TX201… Averag… Tax da…
-#>  9 v_TX2017_10 Total % in appt       Percentage (0-100) v_TX201… Averag… Tax da…
-#> 10 v_TX2017_11 Total All persons - # Number             NA       Additi… Tax da…
-#> # … with 808 more rows, and abbreviated variable names ¹​parent_vector,
-#> #   ²​aggregation
+#> vector type label units parent_vector aggregation details +#> <chr> <fct> <chr> <fct> <chr> <chr> <chr> +#> 1 v_TX2017_1 Total Taxfilers - # Number NA Additive Tax da… +#> 2 v_TX2017_3 Total % 0-24 Percenta… v_TX2017_1 Average of… Tax da… +#> 3 v_TX2017_4 Total % 25-44 Percenta… v_TX2017_1 Average of… Tax da… +#> 4 v_TX2017_5 Total % 45-64 Percenta… v_TX2017_1 Average of… Tax da… +#> 5 v_TX2017_6 Total % 65+ Percenta… v_TX2017_1 Average of… Tax da… +#> 6 v_TX2017_7 Total Average - Age Ratio v_TX2017_1 Average of… Tax da… +#> 7 v_TX2017_8 Total % female Percenta… v_TX2017_1 Average of… Tax da… +#> 8 v_TX2017_9 Total % married Percenta… v_TX2017_1 Average of… Tax da… +#> 9 v_TX2017_10 Total % in appt Percenta… v_TX2017_1 Average of… Tax da… +#> 10 v_TX2017_11 Total All persons - # Number NA Additive Tax da… +#> # ℹ 808 more rows

This particular dataset has over 800 individual vectors. The vector codes follow a regular pattern across different years, and we can use this to quickly identify all the relevant variables of interest across multiple datasets. We can utilized the CensusMapper graphical variable selection interface, which can also be reached by -calling explore_census_vectors() from the R console. For +calling explore_census_vectors() from the R console. For this example we are interested in low income families and note that the internal CensusMapper vector for all families is of the form *v_TX_607* and that for all families in low income is @@ -237,7 +235,7 @@

 years <- c(2006,2011,2014,2018)
 # Attribution for the dataset to be used in graphs
-attribution <- dataset_attribution(paste0("TX",years))
+attribution <- dataset_attribution(paste0("TX",years))
 
 plot_data <- years %>%
   lapply(function(year) {
@@ -245,12 +243,12 @@ 

vectors <- c("Families"=paste0("v_",dataset,"_607"), "CFLIM-AT"=paste0("v_",dataset,"_786")) - get_census(dataset,regions=list(CMA="59933"),vectors = vectors, + get_census(dataset,regions=list(CMA="59933"),vectors = vectors, geo_format = 'sf', level="CT", quiet = TRUE) %>% select(c("GeoUID",names(vectors))) %>% mutate(Year=year) }) %>% - bind_rows() %>% + bind_rows() %>% mutate(share=`CFLIM-AT`/Families)

Here we also re-organized the data by year. All that’s left is to plot the data, one year at a time.

@@ -285,7 +283,7 @@

scale_fill_gradient2(labels=scales::percent) + #scale_fill_viridis_c(labels=scales::percent,option = "inferno") + coord_sf(datum=NA,xlim=c(-123.4, -122.5), ylim=c(49.01, 49.4)) + - labs(title="Change in share of census families in low income 2006-2011",fill="Percentage\npoint change",caption=dataset_attribution(paste0("TX",c(2006,2011)))) + labs(title="Change in share of census families in low income 2006-2011",fill="Percentage\npoint change",caption=dataset_attribution(paste0("TX",c(2006,2011))))

Analyzing change over longer timelines that span changes in Census geometries involves more work, the tongfen @@ -311,7 +309,7 @@

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/cancensus.html b/docs/articles/cancensus.html index fd647ce0..4e890ab0 100644 --- a/docs/articles/cancensus.html +++ b/docs/articles/cancensus.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -144,7 +144,7 @@

Cancensus and CensusMappercancensus, to provide interactive geographic visualizations of Canadian Census data. CensusMapper databases store all publicly available data from Statistics Canada for the 2006, 2011, and -2016 Censuses. Censusmapper data can be accessed via an API and +2016 Censuses. CensusMapper data can be accessed via an API and cancensus is built to interface directly with it.

Installing cancensus @@ -171,31 +171,29 @@

Installing cancensus
 install.packages("cancensus")
 
-library(cancensus)
-
-options(cancensus.api_key = "your_api_key")
-options(cancensus.cache_path = "custom cache path")

+library(cancensus)

Alternatively, the latest development version can be installed from -Github using devtools.

+Github using `remotes``.

 # install.packages("devtools")
-devtools::install_github("mountainmath/cancensus")
+remotes::install_github("mountainmath/cancensus")
 
 library(cancensus)
 
 options(cancensus.api_key = "your_api_key")
 options(cancensus.cache_path = "custom cache path")
-

For performance reasons, and to avoid unnecessarily drawing down API -quotas, cancensus caches data queries under the hood. -By default, cancensus caches in R’s temporary -directory, but this cache is not persistent across sessions. In order to -speed up performance, reduce quota usage, and reduce the need for -unnecessary network calls, we recommend assigning a persistent local -cache using -set_cache_path(<local cache path>, install = TRUE), -this enables more efficient loading and reuse of downloaded data.. Users -will be prompted with a suggestion to change their default cache -location when making API calls if one has not been set yet.

+

If you have not already done so, you can install the API keys and the +data cache path. You can get your free API key when you sign up for a CensusMapper account and check your +profile. Additionally we recommend you set a permanent data cache path +so that census data you query is stored persistently across +sessions.

+
+# Only need to install api key can cache path once
+set_cancensus_api_key('<your_api_key>', install = TRUE)
+set_cancensus_cache_path('<local cache path>', install = TRUE)
+

Data in the persistent cache can be managed via the functions +list_cancensus_cache and +remove_from_cancensus_cache if needed.

@@ -213,19 +211,19 @@

Accessing Census DataNA to return data only, sf to return an sf-class data frame, or sp to return a SpatialPolygonsDataFrame object.

-
+
 # Returns a data frame with data only
-census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
+census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
                           vectors=c("v_CA21_434","v_CA21_435","v_CA21_440"),
                           level='CSD', use_cache = FALSE, geo_format = NA, quiet = TRUE)
 
 # Returns data and geography as an sf-class data frame
-census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
+census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
                           vectors=c("v_CA21_434","v_CA21_435","v_CA21_440"),
                           level='CSD', use_cache = FALSE, geo_format = 'sf', quiet = TRUE)
 
 # Returns a SpatialPolygonsDataFrame object with data and geography
-census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
+census_data <- get_census(dataset='CA21', regions=list(CMA="59933"),
                           vectors=c("v_CA21_434","v_CA21_435","v_CA21_440"),
                           level='CSD', use_cache = FALSE, geo_format = 'sp', quiet = TRUE)

cancensus utilizes caching to increase speed, @@ -236,7 +234,7 @@

Accessing Census Datause_cache = FALSE as a parameter for get_census.

Additional parameters for advanced options can be viewed by running -?get_census.

+?get_census.

Census Datasets

@@ -244,7 +242,7 @@

Census Datasetslist_census_datasets to check what datasets are currently available for access through the CensusMapper API. Additional data for -the 2016 Census will be included in Censusmapper within a day or two +the 2016 Census will be included in CensusMapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their website.

@@ -257,28 +255,27 @@

Census Datasets -

The function list_census_datasets() will show all +

The function list_census_datasets() will show all available datasets alongside their metadata.

-
-list_census_datasets()
+
+list_census_datasets()
 #> # A tibble: 29 × 6
-#>    dataset description                           geo_d…¹ attri…² refer…³ refer…⁴
-#>    <chr>   <chr>                                 <chr>   <chr>   <chr>   <chr>  
-#>  1 CA1996  1996 Canada Census                    CA1996  StatCa… 92-351… https:…
-#>  2 CA01    2001 Canada Census                    CA01    StatCa… 92-378… https:…
-#>  3 CA06    2006 Canada Census                    CA06    StatCa… 92-566… https:…
-#>  4 CA11    2011 Canada Census and NHS            CA11    StatCa… 98-301… https:…
-#>  5 CA16    2016 Canada Census                    CA16    StatCa… 98-301… https:…
-#>  6 CA21    2021 Canada Census                    CA21    StatCa… 98-301… https:…
-#>  7 CA01xSD 2001 Canada Census xtab - Structural… CA01    StatCa… 92-378… https:…
-#>  8 CA06xSD 2006 Canada Census xtab - Structural… CA06    StatCa… 92-566… https:…
-#>  9 CA11xSD 2011 Canada Census xtab - Structural… CA11    StatCa… 98-301… https:…
-#> 10 CA16xSD 2016 Canada Census xtab - Structural… CA16    StatCa… 98-301… https:…
-#> # … with 19 more rows, and abbreviated variable names ¹​geo_dataset,
-#> #   ²​attribution, ³​reference, ⁴​reference_url
+#> dataset description geo_dataset attribution reference reference_url +#> <chr> <chr> <chr> <chr> <chr> <chr> +#> 1 CA1996 1996 Canada Census CA1996 StatCan 19… 92-351-U https://www1… +#> 2 CA01 2001 Canada Census CA01 StatCan 20… 92-378-X https://www1… +#> 3 CA06 2006 Canada Census CA06 StatCan 20… 92-566-X https://www1… +#> 4 CA11 2011 Canada Census a… CA11 StatCan 20… 98-301-X… https://www1… +#> 5 CA16 2016 Canada Census CA16 StatCan 20… 98-301-X https://www1… +#> 6 CA21 2021 Canada Census CA21 StatCan 20… 98-301-X https://www1… +#> 7 CA01xSD 2001 Canada Census x… CA01 StatCan 20… 92-378-X https://www1… +#> 8 CA06xSD 2006 Canada Census x… CA06 StatCan 20… 92-566-X https://www1… +#> 9 CA11xSD 2011 Canada Census x… CA11 StatCan 20… 98-301-X https://www1… +#> 10 CA16xSD 2016 Canada Census x… CA16 StatCan 20… 98-301-X https://www1… +#> # ℹ 19 more rows

As other Census datasets become available via the CensusMapper API, they will be listed as output when calling -list_census_datasets().

+list_census_datasets().

Census Regions @@ -292,29 +289,29 @@

Census Regionscancensus provides a function, list_census_regions(dataset), to display all named census regions and their corresponding id for a given census dataset.

-
-list_census_regions("CA21")
+
+list_census_regions("CA21")
 #> # A tibble: 5,518 × 8
-#>    region name                      level      pop munic…¹ CMA_UID CD_UID PR_UID
-#>    <chr>  <chr>                     <chr>    <int> <chr>   <chr>   <chr>  <chr> 
-#>  1 01     Canada                    C     36991981 NA      NA      NA     NA    
-#>  2 35     Ontario                   PR    14223942 Ont.    NA      NA     NA    
-#>  3 24     Quebec                    PR     8501833 Que.    NA      NA     NA    
-#>  4 59     British Columbia          PR     5000879 B.C.    NA      NA     NA    
-#>  5 48     Alberta                   PR     4262635 Alta.   NA      NA     NA    
-#>  6 46     Manitoba                  PR     1342153 Man.    NA      NA     NA    
-#>  7 47     Saskatchewan              PR     1132505 Sask.   NA      NA     NA    
-#>  8 12     Nova Scotia               PR      969383 N.S.    NA      NA     NA    
-#>  9 13     New Brunswick             PR      775610 N.B.    NA      NA     NA    
-#> 10 10     Newfoundland and Labrador PR      510550 N.L.    NA      NA     NA    
-#> # … with 5,508 more rows, and abbreviated variable name ¹​municipal_status
+#> region name level pop municipal_status CMA_UID CD_UID PR_UID +#> <chr> <chr> <chr> <int> <chr> <chr> <chr> <chr> +#> 1 01 Canada C 3.70e7 NA NA NA NA +#> 2 35 Ontario PR 1.42e7 Ont. NA NA NA +#> 3 24 Quebec PR 8.50e6 Que. NA NA NA +#> 4 59 British Columbia PR 5.00e6 B.C. NA NA NA +#> 5 48 Alberta PR 4.26e6 Alta. NA NA NA +#> 6 46 Manitoba PR 1.34e6 Man. NA NA NA +#> 7 47 Saskatchewan PR 1.13e6 Sask. NA NA NA +#> 8 12 Nova Scotia PR 9.69e5 N.S. NA NA NA +#> 9 13 New Brunswick PR 7.76e5 N.B. NA NA NA +#> 10 10 Newfoundland and … PR 5.11e5 N.L. NA NA NA +#> # ℹ 5,508 more rows

The regions parameter in get_census requires as input a list of region id strings that correspond to that regions geoid. You can combine different regions together into region lists.

-
+
 # Retrieves Vancouver and Toronto
-list_census_regions('CA21') %>% 
+list_census_regions('CA21') %>% 
   filter(level == "CMA", name %in% c("Vancouver","Toronto"))
 #> # A tibble: 2 × 8
 #>   region name      level     pop municipal_status CMA_UID CD_UID PR_UID
@@ -322,7 +319,7 @@ 

Census Regions#> 1 35535 Toronto CMA 6202225 B NA NA 35 #> 2 59933 Vancouver CMA 2642825 B NA NA 59 -census_data <- get_census(dataset='CA21', regions=list(CMA=c("59933","35535")), +census_data <- get_census(dataset='CA21', regions=list(CMA=c("59933","35535")), vectors=c("v_CA21_434","v_CA21_435","v_CA21_440"), level='CSD', use_cache = FALSE, quiet = TRUE)

@@ -422,23 +419,22 @@

Displaying available Census varia

Run list_census_vectors(dataset) to view all available Census variables for a given dataset.

-
-list_census_vectors("CA21")
+
+list_census_vectors("CA21")
 #> # A tibble: 7,709 × 7
-#>    vector    type   label                          units paren…¹ aggre…² details
-#>    <chr>     <fct>  <chr>                          <fct> <chr>   <chr>   <chr>  
-#>  1 v_CA21_1  Total  Population, 2021               Numb… NA      Additi… CA 202…
-#>  2 v_CA21_2  Total  Population, 2016               Numb… NA      Additi… CA 202…
-#>  3 v_CA21_3  Total  Population percentage change,… Numb… NA      Averag… CA 202…
-#>  4 v_CA21_4  Total  Total private dwellings        Numb… NA      Additi… CA 202…
-#>  5 v_CA21_5  Total  Private dwellings occupied by… Numb… v_CA21… Additi… CA 202…
-#>  6 v_CA21_6  Total  Population density per square… Ratio NA      Averag… CA 202…
-#>  7 v_CA21_7  Total  Land area in square kilometres Numb… NA      Additi… CA 202…
-#>  8 v_CA21_8  Total  Total - Age                    Numb… NA      Additi… CA 202…
-#>  9 v_CA21_9  Male   Total - Age                    Numb… NA      Additi… CA 202…
-#> 10 v_CA21_10 Female Total - Age                    Numb… NA      Additi… CA 202…
-#> # … with 7,699 more rows, and abbreviated variable names ¹​parent_vector,
-#> #   ²​aggregation
+#> vector type label units parent_vector aggregation details +#> <chr> <fct> <chr> <fct> <chr> <chr> <chr> +#> 1 v_CA21_1 Total Population, 2021 Numb… NA Additive CA 202… +#> 2 v_CA21_2 Total Population, 2016 Numb… NA Additive CA 202… +#> 3 v_CA21_3 Total Population percenta… Numb… NA Average of… CA 202… +#> 4 v_CA21_4 Total Total private dwell… Numb… NA Additive CA 202… +#> 5 v_CA21_5 Total Private dwellings o… Numb… v_CA21_4 Additive CA 202… +#> 6 v_CA21_6 Total Population density … Ratio NA Average of… CA 202… +#> 7 v_CA21_7 Total Land area in square… Numb… NA Additive CA 202… +#> 8 v_CA21_8 Total Total - Age Numb… NA Additive CA 202… +#> 9 v_CA21_9 Male Total - Age Numb… NA Additive CA 202… +#> 10 v_CA21_10 Female Total - Age Numb… NA Additive CA 202… +#> # ℹ 7,699 more rows

Variable characteristics @@ -468,7 +464,7 @@

## # A tibble: 29 × 6
-##    dataset description                           geo_d…¹ attri…² refer…³ refer…⁴
-##    <chr>   <chr>                                 <chr>   <chr>   <chr>   <chr>  
-##  1 CA1996  1996 Canada Census                    CA1996  StatCa… 92-351… https:…
-##  2 CA01    2001 Canada Census                    CA01    StatCa… 92-378… https:…
-##  3 CA06    2006 Canada Census                    CA06    StatCa… 92-566… https:…
-##  4 CA11    2011 Canada Census and NHS            CA11    StatCa… 98-301… https:…
-##  5 CA16    2016 Canada Census                    CA16    StatCa… 98-301… https:…
-##  6 CA21    2021 Canada Census                    CA21    StatCa… 98-301… https:…
-##  7 CA01xSD 2001 Canada Census xtab - Structural… CA01    StatCa… 92-378… https:…
-##  8 CA06xSD 2006 Canada Census xtab - Structural… CA06    StatCa… 92-566… https:…
-##  9 CA11xSD 2011 Canada Census xtab - Structural… CA11    StatCa… 98-301… https:…
-## 10 CA16xSD 2016 Canada Census xtab - Structural… CA16    StatCa… 98-301… https:…
-## # … with 19 more rows, and abbreviated variable names ¹​geo_dataset,
-## #   ²​attribution, ³​reference, ⁴​reference_url
-

The list_census_datasets() function also provides +## dataset description geo_dataset attribution reference reference_url +## <chr> <chr> <chr> <chr> <chr> <chr> +## 1 CA1996 1996 Canada Census CA1996 StatCan 19… 92-351-U https://www1… +## 2 CA01 2001 Canada Census CA01 StatCan 20… 92-378-X https://www1… +## 3 CA06 2006 Canada Census CA06 StatCan 20… 92-566-X https://www1… +## 4 CA11 2011 Canada Census a… CA11 StatCan 20… 98-301-X… https://www1… +## 5 CA16 2016 Canada Census CA16 StatCan 20… 98-301-X https://www1… +## 6 CA21 2021 Canada Census CA21 StatCan 20… 98-301-X https://www1… +## 7 CA01xSD 2001 Canada Census x… CA01 StatCan 20… 92-378-X https://www1… +## 8 CA06xSD 2006 Canada Census x… CA06 StatCan 20… 92-566-X https://www1… +## 9 CA11xSD 2011 Canada Census x… CA11 StatCan 20… 98-301-X https://www1… +## 10 CA16xSD 2016 Canada Census x… CA16 StatCan 20… 98-301-X https://www1… +## # ℹ 19 more rows +

The list_census_datasets() function also provides additional background like series reference code, catalogue reference, and attribution details.

@@ -183,22 +182,21 @@

Variable vectorsView available Census variable vectors

+list_census_vectors('CA21')
## # A tibble: 7,709 × 7
-##    vector    type   label                          units paren…¹ aggre…² details
-##    <chr>     <fct>  <chr>                          <fct> <chr>   <chr>   <chr>  
-##  1 v_CA21_1  Total  Population, 2021               Numb… NA      Additi… CA 202…
-##  2 v_CA21_2  Total  Population, 2016               Numb… NA      Additi… CA 202…
-##  3 v_CA21_3  Total  Population percentage change,… Numb… NA      Averag… CA 202…
-##  4 v_CA21_4  Total  Total private dwellings        Numb… NA      Additi… CA 202…
-##  5 v_CA21_5  Total  Private dwellings occupied by… Numb… v_CA21… Additi… CA 202…
-##  6 v_CA21_6  Total  Population density per square… Ratio NA      Averag… CA 202…
-##  7 v_CA21_7  Total  Land area in square kilometres Numb… NA      Additi… CA 202…
-##  8 v_CA21_8  Total  Total - Age                    Numb… NA      Additi… CA 202…
-##  9 v_CA21_9  Male   Total - Age                    Numb… NA      Additi… CA 202…
-## 10 v_CA21_10 Female Total - Age                    Numb… NA      Additi… CA 202…
-## # … with 7,699 more rows, and abbreviated variable names ¹​parent_vector,
-## #   ²​aggregation
+## vector type label units parent_vector aggregation details +## <chr> <fct> <chr> <fct> <chr> <chr> <chr> +## 1 v_CA21_1 Total Population, 2021 Numb… NA Additive CA 202… +## 2 v_CA21_2 Total Population, 2016 Numb… NA Additive CA 202… +## 3 v_CA21_3 Total Population percenta… Numb… NA Average of… CA 202… +## 4 v_CA21_4 Total Total private dwell… Numb… NA Additive CA 202… +## 5 v_CA21_5 Total Private dwellings o… Numb… v_CA21_4 Additive CA 202… +## 6 v_CA21_6 Total Population density … Ratio NA Average of… CA 202… +## 7 v_CA21_7 Total Land area in square… Numb… NA Additive CA 202… +## 8 v_CA21_8 Total Total - Age Numb… NA Additive CA 202… +## 9 v_CA21_9 Male Total - Age Numb… NA Additive CA 202… +## 10 v_CA21_10 Female Total - Age Numb… NA Additive CA 202… +## # ℹ 7,699 more rows

list_census_vectors(dataset) retrieves an index of all available vectors for a given dataset from the CensusMapper API or local cache if recently called. Each Census variable has a vector code @@ -223,7 +221,7 @@

Searching for Census variable vec matches; and, semantic search which works better with search phrases and has tolerance for inexact searches. Switching between search modes is done using the query_type argument when calling -find_census_vectors() function.

+find_census_vectors() function.

Note that variable search is optimized for the Census variables in the main Census datasets. While searches generally work for variables in additional datasets such as cross-tabs and taxfiler data, they have not @@ -235,7 +233,7 @@

Searching through named Census r any geographies that have a name that matches or partially matches the search query.

-search_census_regions("Vancouver","CA21")
+search_census_regions("Vancouver","CA21")
## # A tibble: 7 × 8
 ##   region  name              level     pop municipal_status CMA_UID CD_UID PR_UID
 ##   <chr>   <chr>             <chr>   <int> <chr>            <chr>   <chr>  <chr> 
@@ -531,7 +529,7 @@ 

Exploring C

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/index.html b/docs/articles/index.html index 7a2d8daf..1ead90c1 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -136,7 +136,7 @@

Additional datasets

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/intersecting_geometries.html b/docs/articles/intersecting_geometries.html index c3d779fa..dff03aeb 100644 --- a/docs/articles/intersecting_geometries.html +++ b/docs/articles/intersecting_geometries.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -136,7 +136,7 @@

Bring custom data and geographies or other geospatial data of interest and want to be able to quickly and easily identify the collection of census features that correspond to that region.

-

The get_intersecting_geometries() function is projection +

The get_intersecting_geometries() function is projection agnostic and accepts any valid sf or sfc class object as input. These objects are then reprojected into lat/lon coordinates on the backend to facilitate the intersecting join on the @@ -165,9 +165,9 @@

A simple example
-station_city_ids <- get_intersecting_geometries("CA16", level = "CSD", geometry = cov_station_buffers,
+station_city_ids <- get_intersecting_geometries("CA16", level = "CSD", geometry = cov_station_buffers,
                                                 quiet=TRUE)
-station_ct_ids <- get_intersecting_geometries("CA16", level = "CT", geometry = cov_station_buffers,
+station_ct_ids <- get_intersecting_geometries("CA16", level = "CT", geometry = cov_station_buffers,
                                               quiet=TRUE)

These return a list of census geographic identifiers suitable for use in the ‘region’ argument in get_census. We may be @@ -175,10 +175,10 @@

A simple example
 variables <- c(mode_base="v_CA16_5792",transit="v_CA16_5801",walk="v_CA16_5804")
-station_city <-  get_census("CA16", regions = station_city_ids, vectors = variables, 
+station_city <-  get_census("CA16", regions = station_city_ids, vectors = variables, 
                             geo_format = 'sf', quiet=TRUE) %>% 
   filter(name == "Vancouver (CY)")
-station_cts <-   get_census("CA16", regions = station_ct_ids, vectors = variables, 
+station_cts <-   get_census("CA16", regions = station_ct_ids, vectors = variables, 
                             geo_format = 'sf', quiet=TRUE)

To understand how these relate we plot the data.

@@ -195,9 +195,9 @@ 

A simple exampleTo get a closer match we can cut out the dissemination areas intersecting the station catchment areas.

-station_das <-   get_intersecting_geometries("CA16", level = "DA", geometry = cov_station_buffers,
+station_das <-   get_intersecting_geometries("CA16", level = "DA", geometry = cov_station_buffers,
                                              quiet=TRUE) %>% 
-  get_census("CA16", regions = ., vectors=variables, geo_format = 'sf', quiet=TRUE)
+  get_census("CA16", regions = ., vectors=variables, geo_format = 'sf', quiet=TRUE)
 
 ggplot(station_city) +
   geom_sf(fill=NA) +
@@ -215,7 +215,7 @@ 

A simple exampleget_intersecting_geometries call and then filter down to those intersecting the station buffers.

-station_das2 <- get_census("CA16", regions = station_ct_ids, vectors=variables, 
+station_das2 <- get_census("CA16", regions = station_ct_ids, vectors=variables, 
                            geo_format = 'sf', level="DA", quiet=TRUE) %>%
   sf::st_filter(cov_station_buffers)
 
@@ -268,7 +268,7 @@ 

Addendum

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/statcan_attribute_files.html b/docs/articles/statcan_attribute_files.html index 83a31f3d..9e0e90e0 100644 --- a/docs/articles/statcan_attribute_files.html +++ b/docs/articles/statcan_attribute_files.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6

@@ -151,7 +151,7 @@

Match between Censu basic building block of census geographies, and tags other levels of geography the Census Block lies in.

-attributes <- get_statcan_geographic_attributes("2021")
+attributes <- get_statcan_geographic_attributes("2021")
 
 attributes %>% colnames()
 #>  [1] "PRUID_PRIDU"                   "PRDGUID_PRIDUGD"              
@@ -230,7 +230,7 @@ 

Match between Censu

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/articles/statcan_wds.html b/docs/articles/statcan_wds.html index 12d642d5..9c29b172 100644 --- a/docs/articles/statcan_wds.html +++ b/docs/articles/statcan_wds.html @@ -51,7 +51,7 @@ cancensus - 0.5.5 + 0.5.6

@@ -133,7 +133,7 @@

StatCan WDS

library(tidyr) library(ggplot2)

Some census datasets have not been imported into CensusMapper, and -thus aren’t available via the get_census() function. But +thus aren’t available via the get_census() function. But the data can be queried directly from the Statistics Canada Web Data Service for the 2021 census, as well as geographic boundary files.

@@ -156,7 +156,7 @@

Ukrainians by Federal Elector base characteristic for ethnic origin and the entry referencing “Ukrainian” that’s a descendant of the base characteristic.

-metadata <- get_statcan_wds_metadata("2021","FED")
+metadata <- get_statcan_wds_metadata("2021","FED")
 
 characteristics <- metadata |> 
   filter(`Codelist en`=="Characteristic") |>
@@ -167,7 +167,7 @@ 

Ukrainians by Federal Elector ukranian <- characteristics |> filter(grepl("Ukrainian",en), `Parent ID`==ethnic_base$ID) -selected_characteristics <- bind_rows(ethnic_base,ukranian) +selected_characteristics <- bind_rows(ethnic_base,ukranian) selected_characteristics |> select(ID,en) #> # A tibble: 2 × 2 @@ -182,7 +182,7 @@

Ukrainians by Federal Elector filter(`Codelist ID`=="CL_GEO_FED") |> pull(ID)

-data <- get_statcan_wds_data(dguids,members=selected_characteristics$ID,gender="Total")
+data <- get_statcan_wds_data(dguids,members=selected_characteristics$ID,gender="Total")

The data comes enriched with metadata to make working with it easier, in particular the CHARACTERISTIC_NAME column contains plain language names. Now we can transform the data to compute @@ -206,7 +206,7 @@

Ukrainians by Federal Elector

To map the data we have to get the geographies.

-fed_geos <- get_statcan_geographies("2021","FED")
+fed_geos <- get_statcan_geographies("2021","FED")

With these we can join on our census data and map it.

 fed_geos |>
@@ -239,7 +239,7 @@ 

Ukrainians by Federal Elector

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/authors.html b/docs/authors.html index 02fd1809..e3bc0f3c 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6

@@ -126,7 +126,7 @@

Citation

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/index.html b/docs/index.html index f4868f71..662cd63d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -58,7 +58,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -126,7 +126,7 @@
- +

R build status CRAN_Status_Badge CRAN_Downloads_Badge

cancensus logo

Access, retrieve, and work with Canadian Census data and geography.

API key

-

cancensus requires a valid CensusMapper API key to use. You can obtain a free API key by signing up for a CensusMapper account. To check your API key, just go to “Edit Profile” (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter set_cancensus_api_key(<your_api_key>', install = TRUE).

+

cancensus requires a valid CensusMapper API key to use. You can obtain a free API key by signing up for a CensusMapper account. To check your API key, just go to “Edit Profile” (in the top-right of the CensusMapper menu bar). Once you have your key, you can store it in your system environment so it is automatically used in API calls. To do so just enter set_cancensus_api_key('<your_api_key>', install = TRUE).

CensusMapper API keys are free and public API quotas are generous; however, due to incremental costs of serving large quantities of data, there are some limits to API usage in place. For most use cases, these API limits should not be an issue. Production uses with large extracts of detailed geographies may run into API quota limits.

The new get_intersecting_geometries function has a separate API quota. This functionality puts higher demands on server resources than other API calls and therefore comes from a different bucket. By default user keys are capped to 500 region identifiers a day or 5000 per month. This should suffice for most casual use cases, but we will continue to monitor the impact on server load and may increase the default limits in the future.

For larger quotas, please get in touch with Jens directly.

@@ -162,13 +162,13 @@

API key

Local Cache

-

For performance reasons, and to avoid unnecessarily drawing down API quotas, cancensus caches data queries under the hood. By default, cancensus caches in R’s temporary directory, but this cache is not persistent across sessions. In order to speed up performance, reduce quota usage, and reduce the need for unnecessary network calls, we recommend assigning a persistent local cache using set_cancensus_cache_path(<local cache path>, install = TRUE), this enables more efficient loading and reuse of downloaded data. Users will be prompted with a suggestion to change their default cache location when making API calls if one has not been set yet.

-

Starting with version 0.5.2 cancensus will automatically check if for data that has been recalled by Statistics Canada and is stored in the local cache via the new data recall API implemented in CensusMapper. Statistics Canada occasionally detects and corrects errors in their census data releases, and cancensus will download a list of recalled data at the first invocation of get_census() in each session and emit a warning if it detected locally cached data that has been recalled. Removal of the cached recalled data has to be done explicitly by the user via the remove_recalled_chached_data() function. If data was cached with cancensus versions prior to version 0.5.0 there is insufficient metadata to determine all instances of recalled cached data, but the package will check every time cached data is loaded and can identify recalled data at this point at the latest and issues a warning if recalled data is loaded.

+

For performance reasons, and to avoid unnecessarily drawing down API quotas, cancensus caches data queries under the hood. By default, cancensus caches in R’s temporary directory, but this cache is not persistent across sessions. In order to speed up performance, reduce quota usage, and reduce the need for unnecessary network calls, we recommend assigning a persistent local cache using set_cancensus_cache_path('<local cache path>', install = TRUE), this enables more efficient loading and reuse of downloaded data. Users will be prompted with a suggestion to change their default cache location when making API calls if one has not been set yet.

+

Starting with version 0.5.2 cancensus will automatically check if for data that has been recalled by Statistics Canada and is stored in the local cache via the new data recall API implemented in CensusMapper. Statistics Canada occasionally detects and corrects errors in their census data releases, and cancensus will download a list of recalled data at the first invocation of get_census() in each session and emit a warning if it detected locally cached data that has been recalled. Removal of the cached recalled data has to be done explicitly by the user via the remove_recalled_chached_data() function. If data was cached with cancensus versions prior to version 0.5.0 there is insufficient metadata to determine all instances of recalled cached data, but the package will check every time cached data is loaded and can identify recalled data at this point at the latest and issues a warning if recalled data is loaded.

Currently available datasets

-

cancensus can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, 2016, and 2021. You can run list_census_datasets to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2021 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2021 Program which can be viewed on their website.

+

cancensus can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, 2016, and 2021. You can run list_census_datasets to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2021 Census will be included in CensusMapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2021 Program which can be viewed on their website.

Thanks to contributions by the Canada Mortgage and Housing Corporation (CMHC), cancensus now includes additional Census-linked datasets as open-data releases. These include annual taxfiler data at the census tract level for tax years 2000 through 2018, which includes data on incomes and demographics, as well as specialized crosstabs for Structural type of dwelling by Document type, which details occupancy status for residences. These crosstabs are available for the 2001, 2006, 2011, 2016, and 2021 Census years at all levels starting with census tract.

@@ -176,13 +176,13 @@

Picking regions and variables# To view available Census datasets -list_census_datasets() +list_census_datasets() # To view available named regions at different levels of Census hierarchy for the 2016 Census (for example) -list_census_regions("CA16") +list_census_regions("CA16") # To view available Census variables for the 2016 Census -list_census_vectors("CA16") +list_census_vectors("CA16")

There is also an interactive tool that is available at the CensusMapper API to visually select regions and variables and generate code for the API call. Calling explore_census_vectors(dataset = "CA16") or explore_census_regions(dataset = "CA16") will open a new browser window to this interactive tool, preconfigured for whichever Census dataset is set as an argument.

@@ -190,11 +190,11 @@

Getting the data

cancensus can return census data with or without associated Census geographical information that can be used for mapping and GIS. By default, cancensus returns tidy tabular data only, but has options to return spatial data objects in either sf or sp formats.

# Return data only
-census_data <- get_census(dataset='CA16', regions=list(CMA="59933"), 
+census_data <- get_census(dataset='CA16', regions=list(CMA="59933"), 
                           vectors=c("v_CA16_408","v_CA16_409","v_CA16_410"), level='CSD')
 
 # Return an sf-class data frame
-census_data <- get_census(dataset='CA16', regions=list(CMA="59933"), 
+census_data <- get_census(dataset='CA16', regions=list(CMA="59933"), 
                           vectors=c("v_CA16_408","v_CA16_409","v_CA16_410"), level='CSD', geo_format = "sf")

cancensus attempts to minimize bandwidth usage and download time by caching downloads. When attempting to download data that has previously been downloaded, cancensus will instead access the locally cached equivalent.

@@ -274,13 +274,13 @@

Cite cancensus

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.5.

+

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

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.5},
+    note = {R package version 0.5.6},
     url = {https://mountainmath.github.io/cancensus/}
   }
@@ -348,14 +348,7 @@

Developers

-
-

Dev status

-
    -
  • R build status
  • -
  • CRAN_Status_Badge
  • -
  • CRAN_Downloads_Badge
  • -
-
+ @@ -368,7 +361,7 @@

Dev status

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/news/index.html b/docs/news/index.html index 05a00d6c..3411a1b4 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -85,7 +85,14 @@

Changelog

- + +
  • fix issue when using named vectors to query data for non-existent geographies, return NULL in this case instead of throwing error
  • +
  • fix problem with population centre geographic data download
  • +
  • support newly released Forward Sortation Area geography for statcan geography and WDS functionality
  • +
  • remove instances of new native R pipe |> with dplyr pipe %>% to preserve compatibility with older R versions
  • +
+
+
  • add functionality for direct access to StatCan census WDS for 2021
  • add functionality to download original StatCan geographies for 2021
  • update CODES_TABLE for 2021 census
  • @@ -93,7 +100,7 @@
@@ -188,17 +195,17 @@

Minor changescancensus 0.3.0

Major changes

-

Minor changes

@@ -301,7 +308,7 @@

Major changes

Minor changes

-
@@ -339,7 +346,7 @@

Major changes
-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 7508534c..3803eb04 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,5 +1,5 @@ -pandoc: 2.19.2 -pkgdown: 2.0.6 +pandoc: 3.1.1 +pkgdown: 2.0.7 pkgdown_sha: ~ articles: Dwellings_by_document_type_cross_tabulation: Dwellings_by_document_type_cross_tabulation.html @@ -10,7 +10,7 @@ articles: intersecting_geometries: intersecting_geometries.html statcan_attribute_files: statcan_attribute_files.html statcan_wds: statcan_wds.html -last_built: 2023-01-21T22:13Z +last_built: 2023-10-04T15:54Z urls: reference: https://mountainmath.github.io/cancensus/reference article: https://mountainmath.github.io/cancensus/articles diff --git a/docs/reference/CODES_TABLE.html b/docs/reference/CODES_TABLE.html index 9603ac10..ecd2fce0 100644 --- a/docs/reference/CODES_TABLE.html +++ b/docs/reference/CODES_TABLE.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -111,7 +111,7 @@

Author

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/COV_SKYTRAIN_STATIONS.html b/docs/reference/COV_SKYTRAIN_STATIONS.html index b45c32e9..93c5b031 100644 --- a/docs/reference/COV_SKYTRAIN_STATIONS.html +++ b/docs/reference/COV_SKYTRAIN_STATIONS.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -111,7 +111,7 @@

Author

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/add_unique_names_to_region_list.html b/docs/reference/add_unique_names_to_region_list.html index 467a52a3..ba86e5ee 100644 --- a/docs/reference/add_unique_names_to_region_list.html +++ b/docs/reference/add_unique_names_to_region_list.html @@ -26,7 +26,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -135,7 +135,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/as_census_region_list.html b/docs/reference/as_census_region_list.html index cd2b5d66..4e82fb3e 100644 --- a/docs/reference/as_census_region_list.html +++ b/docs/reference/as_census_region_list.html @@ -29,7 +29,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -141,7 +141,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/census_vectors.html b/docs/reference/census_vectors.html index 917e9077..9b70b4e1 100644 --- a/docs/reference/census_vectors.html +++ b/docs/reference/census_vectors.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -133,7 +133,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/child_census_vectors.html b/docs/reference/child_census_vectors.html index 6982bc5c..e5da23ae 100644 --- a/docs/reference/child_census_vectors.html +++ b/docs/reference/child_census_vectors.html @@ -29,7 +29,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -178,7 +178,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/dataset_attribution.html b/docs/reference/dataset_attribution.html index e03bbac3..7057e539 100644 --- a/docs/reference/dataset_attribution.html +++ b/docs/reference/dataset_attribution.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -126,7 +126,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/explore_census_regions.html b/docs/reference/explore_census_regions.html index 26cb9418..bf9080c4 100644 --- a/docs/reference/explore_census_regions.html +++ b/docs/reference/explore_census_regions.html @@ -27,7 +27,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -133,7 +133,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/explore_census_vectors.html b/docs/reference/explore_census_vectors.html index 1633436d..709d1c52 100644 --- a/docs/reference/explore_census_vectors.html +++ b/docs/reference/explore_census_vectors.html @@ -27,7 +27,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -133,7 +133,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/find_census_vectors.html b/docs/reference/find_census_vectors.html index 3673a80d..316e6be8 100644 --- a/docs/reference/find_census_vectors.html +++ b/docs/reference/find_census_vectors.html @@ -36,7 +36,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -181,7 +181,7 @@

Examples

#> 8 v_CA16_2312 Total $10,000 to $19,999 Income… #> 9 v_CA16_2315 Total $20,000 to $29,999 Income… #> 10 v_CA16_2318 Total $30,000 to $39,999 Income… -#> # … with 46 more rows +#> # ℹ 46 more rows if (FALSE) { # This incorrect spelling will return a warning that no match was found, @@ -212,7 +212,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_census.html b/docs/reference/get_census.html index 9a284105..70cbd3f5 100644 --- a/docs/reference/get_census.html +++ b/docs/reference/get_census.html @@ -24,7 +24,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -200,7 +200,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_census_geometry.html b/docs/reference/get_census_geometry.html index f9c3829b..2fb3aeaf 100644 --- a/docs/reference/get_census_geometry.html +++ b/docs/reference/get_census_geometry.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -146,7 +146,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_intersecting_geometries.html b/docs/reference/get_intersecting_geometries.html index 76437046..8484029d 100644 --- a/docs/reference/get_intersecting_geometries.html +++ b/docs/reference/get_intersecting_geometries.html @@ -28,7 +28,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -181,7 +181,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_recalled_database.html b/docs/reference/get_recalled_database.html index 228ac756..754eee91 100644 --- a/docs/reference/get_recalled_database.html +++ b/docs/reference/get_recalled_database.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -129,7 +129,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_geo_suite.html b/docs/reference/get_statcan_geo_suite.html index f1897127..4f519094 100644 --- a/docs/reference/get_statcan_geo_suite.html +++ b/docs/reference/get_statcan_geo_suite.html @@ -25,7 +25,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -139,7 +139,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_geographic_attributes.html b/docs/reference/get_statcan_geographic_attributes.html index 3b076588..24114f34 100644 --- a/docs/reference/get_statcan_geographic_attributes.html +++ b/docs/reference/get_statcan_geographic_attributes.html @@ -27,7 +27,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -138,7 +138,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_geographies.html b/docs/reference/get_statcan_geographies.html index eb10cd0a..e46ed422 100644 --- a/docs/reference/get_statcan_geographies.html +++ b/docs/reference/get_statcan_geographies.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -109,7 +109,7 @@

Arguments

level

geographic level to return the data for, valid choices are -"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR"

+"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"

type
@@ -160,7 +160,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_geography_relationships.html b/docs/reference/get_statcan_geography_relationships.html index 2fc6e8ab..9a306eae 100644 --- a/docs/reference/get_statcan_geography_relationships.html +++ b/docs/reference/get_statcan_geography_relationships.html @@ -26,7 +26,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -137,7 +137,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_wds_data.html b/docs/reference/get_statcan_wds_data.html index 5e837196..f91b8ac4 100644 --- a/docs/reference/get_statcan_wds_data.html +++ b/docs/reference/get_statcan_wds_data.html @@ -25,7 +25,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -155,7 +155,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/get_statcan_wds_metadata.html b/docs/reference/get_statcan_wds_metadata.html index e649e5cd..b42d6605 100644 --- a/docs/reference/get_statcan_wds_metadata.html +++ b/docs/reference/get_statcan_wds_metadata.html @@ -24,7 +24,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -103,7 +103,7 @@

Arguments

level

geographic level to return the data for, valid choices are -"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR"

+"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"

refresh
@@ -137,7 +137,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/index.html b/docs/reference/index.html index 6a49299f..0beb8715 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -107,8 +107,8 @@

Data discovery as_census_region_list()

Convert a (suitably filtered) data frame from -list_census_regions to a list suitable for passing to -get_census.

+list_census_regions to a list suitable for passing to +get_census.

list_census_vectors()

@@ -262,7 +262,7 @@

Data

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/label_vectors.html b/docs/reference/label_vectors.html index 77845aff..94de4893 100644 --- a/docs/reference/label_vectors.html +++ b/docs/reference/label_vectors.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -133,7 +133,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/list_cancensus_cache.html b/docs/reference/list_cancensus_cache.html index 1fd9286b..7722e93d 100644 --- a/docs/reference/list_cancensus_cache.html +++ b/docs/reference/list_cancensus_cache.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -104,21 +104,22 @@

Value

Examples

# list add the cached census data
 list_cancensus_cache()
-#> # A tibble: 1,453 × 11
-#>    path         dataset regions level vectors created_at          version   size
-#>    <chr>        <chr>   <chr>   <chr> <chr>   <dttm>              <chr>    <dbl>
-#>  1 CM_data_009… CA06    "[\"{\… DA    "[]"    2022-05-21 15:28:16 d.1       1663
-#>  2 CM_data_00a… CA16    "[\"{\… DA    "[\"Po… 2022-05-14 16:24:07 d.1      16663
-#>  3 CM_data_014… CA06    "{\"CS… CT    "[\"v_… 2022-11-03 04:34:33 d.3      13801
-#>  4 CM_data_016… CA01    "{\"CS… DB    "[\"Po… 2022-12-12 12:54:14 d.3     179740
-#>  5 CM_data_016… CA16    "[\"{\… DA    "[]"    2022-05-21 15:28:24 d.1       1658
-#>  6 CM_data_01c… CA16    "[\"{\… CT    "[\"v_… 2022-07-13 15:23:08 d.1       5258
-#>  7 CM_data_01f… CA1996  "{\"CS… CSD   "[\"v_… 2022-08-18 19:13:18 d.2       8898
-#>  8 CM_data_024… CA16    "[\"{\… Regi… "[\"v_… 2022-04-27 23:26:47 d.1       3603
-#>  9 CM_data_02b… CA21    "{\"CD… CT    "[\"v_… 2022-12-31 09:37:21 d.4        361
-#> 10 CM_data_02b… CA16    "{\"C\… CT    "[\"v_… 2022-10-06 10:39:55 d.2     143505
-#> # … with 1,443 more rows, and 3 more variables: last_accessed <dttm>,
-#> #   access_count <dbl>, resolution <chr>
+#> # A tibble: 3,278 × 11
+#>    path          dataset regions level vectors created_at          version  size
+#>    <chr>         <chr>   <chr>   <chr> <chr>   <dttm>              <chr>   <dbl>
+#>  1 CM_data_0008… CA16    "{\"CS… Regi… "[\"v_… 2023-06-14 15:39:12 d.4       874
+#>  2 CM_data_0017… CA16    "{\"CS… Regi… "[\"v_… 2023-05-24 18:34:54 d.4       516
+#>  3 CM_data_0023… CA11    "{\"CS… Regi… "[\"v_… 2023-05-16 21:46:25 d.4       485
+#>  4 CM_data_0039… CA21    "{\"CS… Regi… "[\"v_… 2023-05-24 19:32:51 d.4       533
+#>  5 CM_data_0054… CA21    "{\"CS… DA    "[\"v_… 2023-08-28 15:19:19 d.4       620
+#>  6 CM_data_0056… CA16    "{\"CS… Regi… "[\"v_… 2023-05-24 18:32:15 d.4       525
+#>  7 CM_data_006c… CA21    "{\"CS… Regi… "[\"v_… 2023-05-24 18:29:31 d.4       529
+#>  8 CM_data_007f… CA21    "{\"CM… Regi… "[]"    2023-01-26 07:18:01 d.4      1882
+#>  9 CM_data_0084… CA16    "{\"CS… Regi… "[\"v_… 2023-06-14 15:32:37 d.4       707
+#> 10 CM_data_008d… CA11    "{\"CS… Regi… "[\"v_… 2023-05-24 18:36:59 d.4       478
+#> # ℹ 3,268 more rows
+#> # ℹ 3 more variables: last_accessed <dttm>, access_count <dbl>,
+#> #   resolution <chr>
 
 
@@ -134,7 +135,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/list_census_datasets.html b/docs/reference/list_census_datasets.html index 7075ed41..ebe50c71 100644 --- a/docs/reference/list_census_datasets.html +++ b/docs/reference/list_census_datasets.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -124,20 +124,19 @@

Examples

list_census_datasets() #> Reading dataset list from temporary cache. #> # A tibble: 29 × 6 -#> dataset description geo_d…¹ attri…² refer…³ refer…⁴ -#> <chr> <chr> <chr> <chr> <chr> <chr> -#> 1 CA1996 1996 Canada Census CA1996 StatCa… 92-351… https:… -#> 2 CA01 2001 Canada Census CA01 StatCa… 92-378… https:… -#> 3 CA06 2006 Canada Census CA06 StatCa… 92-566… https:… -#> 4 CA11 2011 Canada Census and NHS CA11 StatCa… 98-301… https:… -#> 5 CA16 2016 Canada Census CA16 StatCa… 98-301… https:… -#> 6 CA21 2021 Canada Census CA21 StatCa… 98-301… https:… -#> 7 CA01xSD 2001 Canada Census xtab - Structural… CA01 StatCa… 92-378… https:… -#> 8 CA06xSD 2006 Canada Census xtab - Structural… CA06 StatCa… 92-566… https:… -#> 9 CA11xSD 2011 Canada Census xtab - Structural… CA11 StatCa… 98-301… https:… -#> 10 CA16xSD 2016 Canada Census xtab - Structural… CA16 StatCa… 98-301… https:… -#> # … with 19 more rows, and abbreviated variable names ¹​geo_dataset, -#> # ²​attribution, ³​reference, ⁴​reference_url +#> dataset description geo_dataset attribution reference reference_url +#> <chr> <chr> <chr> <chr> <chr> <chr> +#> 1 CA1996 1996 Canada Census CA1996 StatCan 19… 92-351-U https://www1… +#> 2 CA01 2001 Canada Census CA01 StatCan 20… 92-378-X https://www1… +#> 3 CA06 2006 Canada Census CA06 StatCan 20… 92-566-X https://www1… +#> 4 CA11 2011 Canada Census a… CA11 StatCan 20… 98-301-X… https://www1… +#> 5 CA16 2016 Canada Census CA16 StatCan 20… 98-301-X https://www1… +#> 6 CA21 2021 Canada Census CA21 StatCan 20… 98-301-X https://www1… +#> 7 CA01xSD 2001 Canada Census x… CA01 StatCan 20… 92-378-X https://www1… +#> 8 CA06xSD 2006 Canada Census x… CA06 StatCan 20… 92-566-X https://www1… +#> 9 CA11xSD 2011 Canada Census x… CA11 StatCan 20… 98-301-X https://www1… +#> 10 CA16xSD 2016 Canada Census x… CA16 StatCan 20… 98-301-X https://www1… +#> # ℹ 19 more rows
@@ -152,7 +151,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/list_census_regions.html b/docs/reference/list_census_regions.html index d2fda857..8eec1337 100644 --- a/docs/reference/list_census_regions.html +++ b/docs/reference/list_census_regions.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -155,22 +155,9 @@

Value

Examples

-
list_census_regions('CA16')
-#> Reading regions list from local cache.
-#> # A tibble: 5,518 × 8
-#>    region name                      level      pop munic…¹ CMA_UID CD_UID PR_UID
-#>    <chr>  <chr>                     <chr>    <int> <chr>   <chr>   <chr>  <chr> 
-#>  1 01     Canada                    C     35151728 NA      NA      NA     NA    
-#>  2 35     Ontario                   PR    13448494 NA      NA      NA     NA    
-#>  3 24     Quebec                    PR     8164361 NA      NA      NA     NA    
-#>  4 59     British Columbia          PR     4648055 NA      NA      NA     NA    
-#>  5 48     Alberta                   PR     4067175 NA      NA      NA     NA    
-#>  6 46     Manitoba                  PR     1278365 NA      NA      NA     NA    
-#>  7 47     Saskatchewan              PR     1098352 NA      NA      NA     NA    
-#>  8 12     Nova Scotia               PR      923598 NA      NA      NA     NA    
-#>  9 13     New Brunswick             PR      747101 NA      NA      NA     NA    
-#> 10 10     Newfoundland and Labrador PR      519716 NA      NA      NA     NA    
-#> # … with 5,508 more rows, and abbreviated variable name ¹​municipal_status
+    
if (FALSE) {
+list_census_regions('CA16')
+}
 
@@ -185,7 +172,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/list_census_vectors.html b/docs/reference/list_census_vectors.html index d057b115..6afd20c9 100644 --- a/docs/reference/list_census_vectors.html +++ b/docs/reference/list_census_vectors.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -148,7 +148,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/list_recalled_cached_data.html b/docs/reference/list_recalled_cached_data.html index b7e5e8a5..e3d9b790 100644 --- a/docs/reference/list_recalled_cached_data.html +++ b/docs/reference/list_recalled_cached_data.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -133,7 +133,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/parent_census_vectors.html b/docs/reference/parent_census_vectors.html index 002f2132..0d7f9a32 100644 --- a/docs/reference/parent_census_vectors.html +++ b/docs/reference/parent_census_vectors.html @@ -29,7 +29,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -116,10 +116,9 @@

Examples

# Query parent vectors directly using vector identifier
 parent_census_vectors("v_CA16_2519")
 #> # A tibble: 1 × 7
-#>   vector      type  label                          units paren…¹ aggre…² details
-#>   <chr>       <fct> <chr>                          <fct> <chr>   <chr>   <chr>  
-#> 1 v_CA16_2510 Total Total - Low-income status in … Numb… NA      Additi… CA 201…
-#> # … with abbreviated variable names ¹​parent_vector, ²​aggregation
+#>   vector      type  label                units parent_vector aggregation details
+#>   <chr>       <fct> <chr>                <fct> <chr>         <chr>       <chr>  
+#> 1 v_CA16_2510 Total Total - Low-income … Numb… NA            Additive    CA 201…
 if (FALSE) {
 # Example using multiple vectors coerced into a list
 parent_census_vectors(c("v_CA16_2519","v_CA16_2520","v_CA16_2521"))
@@ -149,7 +148,7 @@ 

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/remove_from_cancensus_cache.html b/docs/reference/remove_from_cancensus_cache.html index a2c0b78f..129a4224 100644 --- a/docs/reference/remove_from_cancensus_cache.html +++ b/docs/reference/remove_from_cancensus_cache.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -128,7 +128,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/remove_recalled_cached_data.html b/docs/reference/remove_recalled_cached_data.html index 937014c7..3b500fad 100644 --- a/docs/reference/remove_recalled_cached_data.html +++ b/docs/reference/remove_recalled_cached_data.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -119,7 +119,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/search_census_regions.html b/docs/reference/search_census_regions.html index 4bc26268..712574c2 100644 --- a/docs/reference/search_census_regions.html +++ b/docs/reference/search_census_regions.html @@ -27,7 +27,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -153,7 +153,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/search_census_vectors.html b/docs/reference/search_census_vectors.html index fa843220..cc07ef55 100644 --- a/docs/reference/search_census_vectors.html +++ b/docs/reference/search_census_vectors.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -121,20 +121,19 @@

Examples

search_census_vectors('Ojibway', 'CA16')
 #> Warning: search_census_vectors(). See ?find_census_vectors() for more robust search functions.
 #> # A tibble: 24 × 7
-#>    vector      type   label                        units paren…¹ aggre…² details
-#>    <chr>       <fct>  <chr>                        <fct> <chr>   <chr>   <chr>  
-#>  1 v_CA16_617  Total  Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#>  2 v_CA16_618  Male   Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#>  3 v_CA16_619  Female Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#>  4 v_CA16_623  Total  Ojibway                      Numb… v_CA16… Additi… CA 201…
-#>  5 v_CA16_624  Male   Ojibway                      Numb… v_CA16… Additi… CA 201…
-#>  6 v_CA16_625  Female Ojibway                      Numb… v_CA16… Additi… CA 201…
-#>  7 v_CA16_1424 Total  Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#>  8 v_CA16_1425 Male   Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#>  9 v_CA16_1426 Female Ojibway-Potawatomi languages Numb… v_CA16… Additi… CA 201…
-#> 10 v_CA16_1430 Total  Ojibway                      Numb… v_CA16… Additi… CA 201…
-#> # … with 14 more rows, and abbreviated variable names ¹​parent_vector,
-#> #   ²​aggregation
+#>    vector      type   label              units parent_vector aggregation details
+#>    <chr>       <fct>  <chr>              <fct> <chr>         <chr>       <chr>  
+#>  1 v_CA16_617  Total  Ojibway-Potawatom… Numb… v_CA16_569    Additive    CA 201…
+#>  2 v_CA16_618  Male   Ojibway-Potawatom… Numb… v_CA16_570    Additive    CA 201…
+#>  3 v_CA16_619  Female Ojibway-Potawatom… Numb… v_CA16_571    Additive    CA 201…
+#>  4 v_CA16_623  Total  Ojibway            Numb… v_CA16_617    Additive    CA 201…
+#>  5 v_CA16_624  Male   Ojibway            Numb… v_CA16_618    Additive    CA 201…
+#>  6 v_CA16_625  Female Ojibway            Numb… v_CA16_619    Additive    CA 201…
+#>  7 v_CA16_1424 Total  Ojibway-Potawatom… Numb… v_CA16_1376   Additive    CA 201…
+#>  8 v_CA16_1425 Male   Ojibway-Potawatom… Numb… v_CA16_1377   Additive    CA 201…
+#>  9 v_CA16_1426 Female Ojibway-Potawatom… Numb… v_CA16_1378   Additive    CA 201…
+#> 10 v_CA16_1430 Total  Ojibway            Numb… v_CA16_1424   Additive    CA 201…
+#> # ℹ 14 more rows
 if (FALSE) {
 # This will return a warning that no match was found, but will suggest similar terms.
 search_census_vectors('Ojibwe', 'CA16', 'Total')
@@ -153,7 +152,7 @@ 

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/set_cancensus_api_key.html b/docs/reference/set_cancensus_api_key.html index 7716eafc..4b5c8966 100644 --- a/docs/reference/set_cancensus_api_key.html +++ b/docs/reference/set_cancensus_api_key.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -130,7 +130,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/set_cancensus_cache_path.html b/docs/reference/set_cancensus_cache_path.html index b9d1c092..cb0b31c7 100644 --- a/docs/reference/set_cancensus_cache_path.html +++ b/docs/reference/set_cancensus_cache_path.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -130,7 +130,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/show_cancensus_api_key.html b/docs/reference/show_cancensus_api_key.html index ffe240d2..995d5a80 100644 --- a/docs/reference/show_cancensus_api_key.html +++ b/docs/reference/show_cancensus_api_key.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -112,7 +112,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/docs/reference/show_cancensus_cache_path.html b/docs/reference/show_cancensus_cache_path.html index ef36f064..2125a52e 100644 --- a/docs/reference/show_cancensus_cache_path.html +++ b/docs/reference/show_cancensus_cache_path.html @@ -23,7 +23,7 @@ cancensus - 0.5.5 + 0.5.6 @@ -112,7 +112,7 @@

Examples

-

Site built with pkgdown 2.0.6.

+

Site built with pkgdown 2.0.7.

diff --git a/man/get_statcan_geographies.Rd b/man/get_statcan_geographies.Rd index 1a17d3bf..4ac50e88 100644 --- a/man/get_statcan_geographies.Rd +++ b/man/get_statcan_geographies.Rd @@ -18,7 +18,7 @@ get_statcan_geographies( \item{census_year}{census year to get the data for, right now only 2021 is supported} \item{level}{geographic level to return the data for, valid choices are -"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR"} +"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"} \item{type}{type of geographic data, valid choices area "cartographic" or "digital"} diff --git a/man/get_statcan_wds_metadata.Rd b/man/get_statcan_wds_metadata.Rd index 9fec9992..ba0c8e15 100644 --- a/man/get_statcan_wds_metadata.Rd +++ b/man/get_statcan_wds_metadata.Rd @@ -10,7 +10,7 @@ get_statcan_wds_metadata(census_year, level, refresh = FALSE) \item{census_year}{census year to get the data for, right now only 2021 is supported} \item{level}{geographic level to return the data for, valid choices are -"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR"} +"PR","CD","CMACA","CSD","CT","ADA","DA","ER","FED","DPL","POPCNTR", "FSA"} \item{refresh}{default is `FALSE` will refresh the temporary cache if `TRUE`} } diff --git a/man/list_census_regions.Rd b/man/list_census_regions.Rd index 2e224e92..facb9a19 100644 --- a/man/list_census_regions.Rd +++ b/man/list_census_regions.Rd @@ -43,5 +43,7 @@ Returns a data frame with the following columns: Query the CensusMapper API for available regions in a given dataset. } \examples{ +\dontrun{ list_census_regions('CA16') } +} diff --git a/vignettes/cancensus.Rmd b/vignettes/cancensus.Rmd index 775f8860..78f67a20 100644 --- a/vignettes/cancensus.Rmd +++ b/vignettes/cancensus.Rmd @@ -19,13 +19,14 @@ knitr::opts_chunk$set( ) library(cancensus) library(dplyr) -# set_api_key(, install = TRUE) +# set_cancensus_api_key(', install = TRUE) +# set_cancensus_cache_path(, install = TRUE) ``` # Cancensus and CensusMapper The **cancensus** package was developed to provide users with a way to access Canadian Census in a programmatic way following good [tidy data](http://vita.had.co.nz/papers/tidy-data.pdf) practices. While the structure and data in **cancensus** is unique to Canadian Census data, this package is inspired in part by [tidycensus](https://github.com/walkerke/tidycensus), a package to interface with the US Census Bureau data APIs. -As Statistics Canada does not provide direct API access to Census data, **cancensus** retrieves Census data indirectly through the [CensusMapper](https://censusmapper.ca) API. CensusMapper is a project by [Jens von Bergmann](https://github.com/mountainMath), one of the authors of **cancensus**, to provide interactive geographic visualizations of Canadian Census data. CensusMapper databases store all publicly available data from Statistics Canada for the 2006, 2011, and 2016 Censuses. Censusmapper data can be accessed via an API and **cancensus** is built to interface directly with it. +As Statistics Canada does not provide direct API access to Census data, **cancensus** retrieves Census data indirectly through the [CensusMapper](https://censusmapper.ca) API. CensusMapper is a project by [Jens von Bergmann](https://github.com/mountainMath), one of the authors of **cancensus**, to provide interactive geographic visualizations of Canadian Census data. CensusMapper databases store all publicly available data from Statistics Canada for the 2006, 2011, and 2016 Censuses. CensusMapper data can be accessed via an API and **cancensus** is built to interface directly with it. ## API Key @@ -40,15 +41,12 @@ The stable version of **cancensus** can be easily installed from CRAN. install.packages("cancensus") library(cancensus) - -options(cancensus.api_key = "your_api_key") -options(cancensus.cache_path = "custom cache path") ``` -Alternatively, the latest development version can be installed from Github using `devtools`. +Alternatively, the latest development version can be installed from Github using `remotes``. ```{r load_package_git, echo=TRUE, message=FALSE, warning=FALSE, eval = FALSE} # install.packages("devtools") -devtools::install_github("mountainmath/cancensus") +remotes::install_github("mountainmath/cancensus") library(cancensus) @@ -56,7 +54,15 @@ options(cancensus.api_key = "your_api_key") options(cancensus.cache_path = "custom cache path") ``` -For performance reasons, and to avoid unnecessarily drawing down API quotas, **cancensus** caches data queries under the hood. By default, **cancensus** caches in R's temporary directory, but this cache is not persistent across sessions. In order to speed up performance, reduce quota usage, and reduce the need for unnecessary network calls, we recommend assigning a persistent local cache using `set_cache_path(, install = TRUE)`, this enables more efficient loading and reuse of downloaded data.. Users will be prompted with a suggestion to change their default cache location when making API calls if one has not been set yet. +If you have not already done so, you can install the API keys and the data cache path. You can get your free API key when you sign up for a [CensusMapper account](https://censusmapper.ca/) and check your profile. Additionally we recommend you set a permanent data cache path so that census data you query is stored persistently across sessions. + +```{r install_api_key_and_cache_path, echo=TRUE, message=FALSE, warning=FALSE, eval = FALSE} +# Only need to install api key can cache path once +set_cancensus_api_key('', install = TRUE) +set_cancensus_cache_path('', install = TRUE) +``` + +Data in the persistent cache can be managed via the functions `list_cancensus_cache` and `remove_from_cancensus_cache` if needed. # Accessing Census Data @@ -90,7 +96,7 @@ Additional parameters for advanced options can be viewed by running `?get_census ## Census Datasets -**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, and 2016 . You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in Censusmapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm). +**cancensus** can access Statistics Canada Census data for Census years 1996, 2001, 2006, 2011, and 2016 . You can run `list_census_datasets` to check what datasets are currently available for access through the CensusMapper API. Additional data for the 2016 Census will be included in CensusMapper within a day or two after public release by Statistics Canada. Statistics Canada maintains a release schedule for the Census 2016 Program which can be viewed on their [website](http://www12.statcan.gc.ca/census-recensement/2016/ref/release-dates-diffusion-eng.cfm). Thanks to contributions by the Canada Mortgage and Housing Corporation (CMHC), **cancensus** now includes additional Census-linked datasets as open-data releases. These include annual taxfiler data at the census tract level for tax years 2000 through 2017, which includes data on incomes and demographics, as well as specialized crosstabs for Structural type of dwelling by Document type, which details occupancy status for residences. These crosstabs are available for the 2001, 2006, 2011, and 2016 Census years at all levels starting with census tract.