Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
/ census_geography_bc Public archive

R scripts for working with Statistics Canada's Census geography files

License

Notifications You must be signed in to change notification settings

bcgov/census_geography_bc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img

census_geography_bc

Usage

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)

Example: Census Metropolitan Area

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"))

Project Status

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an issue.

How to Contribute

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.

License

Copyright 2019 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
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 &quot;AS IS&quot; 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.

Releases

No releases published

Packages

No packages published

Languages