pycensus.cadaster¶
Cadaster / building sources: one row per building with its built floor area, in one unified schema.
Layout: pycensus/cadaster/<country>/<source>/ with a loader.py (download + load(aoi, cache_dir)) and a schema.json (how the
source's own fields map onto the global schema pycensus/cadaster/global_schema.json, and its use codes onto the unified
use_class). The worldwide fallback is GlobalBuildingAtlas (cadaster/worldwide/gba, footprints + heights everywhere).
from pycensus import cadaster
b = cadaster.load_buildings("ESP", aoi, cache_dir) # every source covering the AOI, GBA where no cadaster has buildings
b = cadaster.load("es_catastro", aoi, cache_dir) # one source
None of the sources needs an API key.
source_schema(source)
¶
The schema JSON of one cadaster source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source name (a key of |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The schema as a dict. |
cache_root(cache_dir)
¶
The cadaster cache folder (created): <cache_dir or the pycensus cache>/cadaster.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_dir
|
Cache folder; |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The folder. |
aoi_key(aoi)
¶
Short hash of an area's geometry, used to name its cached files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
aoi
|
GeoDataFrame
|
Area of interest (GeoDataFrame). |
required |
Returns:
| Type | Description |
|---|---|
str
|
12-character key. |
true_area_m2(geoms)
¶
Polygon areas in m2 from any CRS (local equal-area projection).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geoms
|
GeoSeries
|
Polygons in any CRS. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Areas in m2. |
map_use(codes, use_map, prefix_match=False)
¶
Source use codes -> unified use_class (unknown when unmapped). With prefix_match, the longest mapped prefix of each code wins.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
codes
|
Iterable
|
Source use codes. |
required |
use_map
|
dict
|
|
required |
prefix_match
|
bool
|
Match code prefixes. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of use classes. |
standardize(df, source, country)
¶
Every global column present (null where unknown), in schema order, EPSG:4326; built_area_m2 filled from floors x footprint or height x footprint when the source gave no floor area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
GeoDataFrame
|
Buildings of one source. |
required |
source
|
str
|
Source name. |
required |
country
|
str
|
Country code. |
required |
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The buildings in the unified schema. |
load(source, aoi, cache_dir=None, refresh=False)
¶
One source's buildings inside aoi (centroid inside), unified schema, cached as parquet per AOI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
Source name (a key of |
required |
aoi
|
GeoDataFrame
|
Area of interest (GeoDataFrame). |
required |
cache_dir
|
Cache folder; |
None
|
|
refresh
|
bool
|
Ignore the cached file. |
False
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The buildings (unified schema). |
load_buildings(country, aoi, cache_dir=None, sources=None, gba_fill=True, fill_resolution=8)
¶
Every cadaster source of country covering the AOI (best first: a building of a later source is dropped where an earlier one already
has buildings in the same res-fill_resolution H3 cell), then GBA in the cells no cadaster covers. Unified schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country
|
str
|
Country code (keys of |
required |
aoi
|
GeoDataFrame
|
Area of interest (GeoDataFrame). |
required |
cache_dir
|
Cache folder; |
None
|
|
sources
|
Optional[List[str]]
|
Sources in priority order; |
None
|
gba_fill
|
bool
|
Fill cells no cadaster covers with GBA buildings. |
True
|
fill_resolution
|
int
|
H3 resolution of the coverage test. |
8
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
The buildings (unified schema). |