Skip to content

pycensus.census.countries.canada.statcan

Statistics Canada (StatCan) 2021 Census source.

Importing this module registers the gdf.statcan GeoDataFrame accessor (see :mod:pycensus.accessors). Use :func:load to fetch data.

Technical aspects

StatCan has no per-region queryable API used here -- data is fetched via the Full Table Download (bulk CSV) route (:mod:pycensus.canada.api), the same shape as :mod:pycensus.mexico.inegi's ITER downloader.

Source

https://www150.statcan.gc.ca/n1/en/tbl/csv/98100002-eng.zip

load(aoi=None, provinces=None, level='municipality', year='latest', cache_dir=None, cache=True, data_dir=None)

Load StatCan 2021 Census data as a common-schema GeoDataFrame.

Parameters:

Name Type Description Default
aoi Optional[GeoDataFrame]

Area of interest. Used to auto-detect provinces if not given (via :func:pycensus.canada.geography.provinces_in_aoi), and to clip the final result.

None
provinces Optional[Union[str, List[str]]]

Province name(s)/abbreviation(s)/PRUID(s) to load. Derived from aoi if omitted (aoi is then required).

None
level str

Standard geometry level name. Only "province" and "municipality" are implemented; other standard levels fall back onto one of those two via :data:pycensus.canada.constants.LEVEL_FALLBACK where possible, else raise.

'municipality'
year Union[int, str]

Vintage year, or "latest". Only 2021 is available.

'latest'
cache_dir Optional[str]

Root of pyCensus' parquet cache. Defaults to :func:pycensus.cache.default_cache_dir.

None
cache bool

If False, bypass the parquet cache entirely -- always fetch fresh and don't persist the result. StatCan's own raw Full Table Download / boundary downloads (:mod:pycensus.canada.api, :mod:pycensus.canada.geography) are cached on disk independently of this flag.

True
data_dir Optional[str]

Base directory for StatCan's raw downloaded files (Census Profile CSV, boundary zips). Defaults to :data:pycensus.canada.constants.DEFAULT_DATA_DIR.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame with GEOID, geometry, and one statcan_-prefixed

GeoDataFrame

column per logical column in :data:pycensus.canada.statcan.schema.SCHEMA.

Raises:

Type Description
ValueError

If neither provinces nor aoi is given, or level has no implemented data source.