Skip to content

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