These scripts take geographic boundary files made available by Statistics Canada (under the Statistics Canada Open License), and convert them to .RDS files, which can be read into R and used for mapping etc.
Boundary files should be downloaded from this site:
Folder structure within this project is
-
\scr\ -- for scripts
-
\geography\
-
(geolevel)_canada -- for the source shape files and a national *.RDS file for that level of geography
-
\bc_geog -- for all B.C. files (which are sub-sets of the national .RDS files)
-
File lcma000b16a_e.zip
downloaded from 2016 Census - Boundary files, after selecting "Census metropolitan areas and census agglomerations" in the "Cartographic Boundary File" column.
This file is then saved to folder \geography\cma_canada
, and unzipped.
The following script will
-
open the file (using the {sf} package),
-
save it as an .RDS file in the above folder,
-
filter only the B.C. regions (using the provincial code of "59"), and
-
save the B.C. file in
\geography\bc_geog
.
# PACKAGES
# the tidyverse
library(dplyr)
library(forcats)
library(glue)
# utilities
library(here)
# mapping
library(sf)
# read and save Canada file
canada_cma <- st_read(here::here("geography", "cma_canada", "lcma_000b16a_e.shp"))
saveRDS(canada_cma, here("geography", "cma_canada", "canada_cma.RDS"))
# filter B.C. geography
bc_cma <-
canada_cma %>%
filter(PRUID == "59") %>%
mutate(PRUID = fct_drop(PRUID))
saveRDS(bc_cma, here("geography", "bc_geog", "bc_cma.RDS"))
To report bugs/issues/feature requests, please file an issue.
If you would like to contribute, please see our CONTRIBUTING guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Copyright 2019 Province of British Columbia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
This project was created using the bcgovr package.