pycensus.census.countries.canada.statcan.loader¶
Loader for StatCan 2021 Census Population and Dwelling Counts, returning a common-schema GeoDataFrame.
Technical aspects
Mirrors :mod:pycensus.mexico.inegi.loader's shape: reads as much as
possible from pyCensus' parquet cache (:mod:pycensus.cache),
fetching only the logical columns actually missing. Like Mexico,
StatCan's Full Table Download has no per-region query -- the whole
Census Profile table (PID 98-10-0002) is downloaded once and cached
on disk (:mod:pycensus.canada.api) the first time any column is
requested, then every subsequent request is served from that file.
province, municipality, dissemination-area, and
dissemination-block levels are implemented. Dissemination-area
population comes from a separate, companion Full Table Download cube
(PID 98-10-0015 -- 98100002 stops at the census-subdivision level) --
see :func:pycensus.canada.api.fetch_dissemination_area_totals.
Dissemination-block population comes from a different source again --
the 2021 Geographic Attribute File (catalogue 92-151-X), StatCan's
finest unit is not part of the Full Table Download cube family -- see
:func:pycensus.canada.api.fetch_block_totals. This was live-verified
2026-08-22 to be real per-block population/dwelling counts, not a
populated/unpopulated boolean flag: summing the GAF's DB-level
population over every one of Toronto's 3,743 real dissemination areas
exactly reproduces PID 98-10-0015's own published DA-level population
(0 mismatches across all 3,743 DAs), and the grand total across all
matched Toronto blocks (2,794,356) exactly matches the City of
Toronto's published CSD population. Spot-checked individually across
4 different Toronto neighborhoods (downtown core DA 35204609,
North York DA 35204196, Scarborough DA 35203712, Etobicoke DA
35201868) -- each DA's block-level population sum matched its
official DA-level population exactly.
Source
StatCan 2021 Census: 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 |
None
|
provinces
|
Optional[Union[str, List[str]]]
|
Province name(s)/abbreviation(s)/PRUID(s) to load.
Derived from |
None
|
level
|
str
|
Standard geometry level name. Only |
'municipality'
|
year
|
Union[int, str]
|
Vintage year, or |
'latest'
|
cache_dir
|
Optional[str]
|
Root of pyCensus' parquet cache. Defaults to
:func: |
None
|
cache
|
bool
|
If |
True
|
data_dir
|
Optional[str]
|
Base directory for StatCan's raw downloaded files
(Census Profile CSV, boundary zips). Defaults to
:data: |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with |
GeoDataFrame
|
column per logical column in :data: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither |