HDX catalog explorer (no network)¶
Browse the curated Humanitarian Data Exchange catalogue shipped with earthlens — no network or [hdx] extra needed to read it. See the Catalog reference.
Setup¶
Load the curated catalogue. Catalog() reads the YAML data shipped with the package, so this works entirely offline; len(catalog) reports how many curated datasets it holds.
from collections import Counter
from earthlens.hdx import Catalog
catalog = Catalog()
print('curated datasets:', len(catalog))
What's in the catalogue¶
Tally the curated rows two ways — by output_kinds (raster / vector / tabular) and by source org — to get a feel for the shape of the holdings.
kinds = Counter(k for row in catalog.datasets.values() for k in row.output_kinds)
print('by output kind:', dict(kinds))
orgs = Counter(row.org for row in catalog.datasets.values())
print('by organisation:', dict(orgs))
Inspect one dataset¶
resolve() looks up a single curated row by key and returns its metadata — the upstream hdx_id, owning org, available formats, the resource_filter used to pick files, and its output_kinds.
row = catalog.resolve('kontur-population')
print('hdx_id :', row.hdx_id)
print('org :', row.org)
print('formats :', row.formats)
print('filter :', row.resource_filter)
print('kinds :', row.output_kinds)
Helpful errors¶
Unknown keys raise a did-you-mean ValueError rather than a bare KeyError, so a typo points you at the closest real key.
try:
catalog.get_dataset('kontur-populaton')
except ValueError as exc:
print(exc)
The wider available index¶
Beyond the curated rows, available_datasets is an informational index of the curated orgs' wider holdings on HDX.
print('available index size:', len(catalog.available_datasets))