Skip to content

pycensus.census.countries.spain.censo2021

Spain Censo de Poblacion y Viviendas 2021 (SDC21) source.

See :mod:pycensus.census.countries.spain.censo2021.api and loader.py module docstrings for the real, live-verified source details and exactly which fields are implemented.

load(aoi=None, regions=None, level='section', year='latest', api_key=None, cache_dir=None, cache=True, data_dir=None)

Load INE's Censo 2021 (SDC21) data as a common-schema GeoDataFrame.

Parameters:

Name Type Description Default
aoi Optional[GeoDataFrame]

Area of interest. Used to auto-detect regions if not given, and to clip the final result.

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

Region code(s) -- autonomous community code, province code, or 5-digit municipality code, matching level. Derived from aoi if omitted (aoi is then required).

None
level str

Standard geometry level name. Uses the same real, live-verified boundary levels as spain.ine.load (nation/autonomous_community/province/municipality/section), since both sources share :mod:pycensus.census.countries.spain.geography.

'section'
year Union[int, str]

Vintage year. SDC21's 2021 census is the only vintage (accepted for interface parity; not otherwise used).

'latest'
api_key Optional[str]

Not used -- SDC21's API requires no API key.

None
cache_dir Optional[str]

Root of pyCensus' parquet cache.

None
cache bool

If False, bypass the parquet cache entirely.

True
data_dir Optional[str]

Root directory for raw SDC21 downloads.

None

Returns:

Type Description
GeoDataFrame

GeoDataFrame with GEOID, geometry, and one censo2021_

GeoDataFrame

(canonicalized where a bare global-schema name applies) column per

GeoDataFrame

logical column implemented in

GeoDataFrame

mod:pycensus.census.countries.spain.censo2021.schema.

Raises:

Type Description
ValueError

If neither regions nor aoi is given.

NotImplementedError

If level resolves to a level without a real boundary source (see :mod:pycensus.census.countries.spain.geography).