pycensus.census.countries.euskadi.geography¶
Boundary fetching shared by every Euskadi census source.
Technical aspects
Boundaries and population come from Eurostat/GISCO's LAU (Local
Administrative Units) 2021 GeoPackage, a real, keyless, EU-published
cartography product that republishes each Spanish municipality's
official INE-sourced boundary together with a real POP_2021 figure:
https://gisco-services.ec.europa.eu/distribution/v2/lau/gpkg/LAU_RG_01M_2021_4326.gpkg
Verified 2026-08-19 against real downloaded data: filtering to Spanish
LAU_ID codes starting with "20" (Gipuzkoa) yields exactly 88
municipalities totalling POP_2021 = 726,033; "01" (Araba) yields 51
municipalities / 333,626 people; "48" (Bizkaia) yields 112
municipalities / 1,154,334 people -- all three match real, documented
2021 population totals for Euskadi's historical territories. Euskadi's
own geographic data portals (opendata.euskadi.eus,
eustat.eus/geoservicios/descargas.html) remain genuinely
unreachable to a scripted client (404/403) -- see euskadi/api.py's
module docstring for the (separate, reachable) Eustat data API this
module does not yet use for geometry.
Only municipality boundaries are downloaded directly.
territory/autonomous_community boundaries are built by
dissolving municipality geometries: a Spanish LAU_ID's first two
characters are the province code, which for Euskadi's three provinces
is exactly the historical-territory code (see
:data:pycensus.euskadi.constants.TERRITORY_CODES).
comarca/district/section/block have no real, verified
boundary source wired up in this rebuild and are not present in
:data:GEOMETRY_LEVELS -- requesting them raises KeyError rather
than fabricating placeholder geometry (see
:data:pycensus.euskadi.constants.LEVEL_FALLBACK, which now resolves
every standard level to one of the three real ones instead).
The downloaded GeoPackage is cached on disk under
<cache_dir>/raw/euskadi_gisco_lau/, persistent across runs,
independent of :mod:pycensus.cache's parquet cache (which caches the
already-filtered per-region result one level higher, in
eustat/loader.py).
Only the 2021 vintage is implemented -- load_boundaries raises
ValueError for any other year.
Source
https://gisco-services.ec.europa.eu/distribution/v2/lau/lau-2021-files.html
territories_in_aoi(aoi, year=2021, cache_dir=None)
¶
Return the two-digit codes of every territory intersecting aoi.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi
|
GeoDataFrame
|
Area of interest, any CRS. |
required |
year
|
int
|
Geographic data vintage year (default 2021, the only one implemented). |
2021
|
cache_dir
|
Optional[str]
|
Root of the raw GISCO cache. |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of two-digit territory codes (01=Araba, 48=Bizkaia, 20=Gipuzkoa). |
load_boundaries(level, region=None, year=2021, erase_water=None, cache_dir=None)
¶
Fetch boundaries for one Euskadi geography level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
Standard geometry level name, resolved through
:data: |
required |
region
|
Optional[str]
|
Territory name/abbreviation/code. If |
None
|
year
|
int
|
Vintage year -- only 2021 (GISCO LAU's vintage) is implemented. |
2021
|
erase_water
|
Optional[bool]
|
Whether to clip inland water bodies. Defaults to
:data: |
None
|
cache_dir
|
Optional[str]
|
Root of the raw GISCO cache. |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with a |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
ValueError
|
If |
load_boundaries_multi(level, regions=None, year=2021, erase_water=None, aoi=None, cache_dir=None)
¶
Fetch and concatenate boundaries across one or more regions, optionally clipped to an AOI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str
|
Standard geometry level name. |
required |
regions
|
Optional[Union[str, List[str]]]
|
Territory name(s)/abbreviation(s)/code(s). If |
None
|
year
|
int
|
Vintage year (see :func: |
2021
|
erase_water
|
Optional[bool]
|
Whether to clip inland water bodies. |
None
|
aoi
|
Optional[GeoDataFrame]
|
If given, the result is filtered to geometries intersecting it. |
None
|
cache_dir
|
Optional[str]
|
Root of the raw GISCO cache. |
None
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
GeoDataFrame with a |
states_in_aoi(aoi, year=2021, cache_dir=None)
¶
Return the Eustat codes of every territory intersecting aoi.
This function is kept for interface parity with the USA implementation. In Euskadi, the equivalent of states are historical territories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi
|
GeoDataFrame
|
Area of interest (GeoDataFrame). |
required |
year
|
int
|
Boundary year. |
2021
|
cache_dir
|
Optional[str]
|
Cache folder; |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
Territory codes. |