IUCN catalog explorer (no network)¶
Browse the curated IUCN country catalog and the selector resolution — entirely offline, with no token and no API call. Species are selected by binomial (species:<name>), but countries come from this catalog, which maps friendly names to the ISO2 codes the Red List v4 countries/{code} endpoint expects.
Load the catalog¶
In [ ]:
Copied!
import pandas as pd
from earthlens.iucn import Catalog
catalog = Catalog()
print(f"{len(catalog)} curated countries")
import pandas as pd
from earthlens.iucn import Catalog
catalog = Catalog()
print(f"{len(catalog)} curated countries")
The curated countries, by region¶
In [ ]:
Copied!
rows = [
{"iso2": code, "name": country.name, "region": country.region}
for code, country in catalog.datasets.items()
]
frame = pd.DataFrame(rows).sort_values(["region", "name"]).reset_index(drop=True)
frame.groupby("region").size().rename("countries")
rows = [
{"iso2": code, "name": country.name, "region": country.region}
for code, country in catalog.datasets.items()
]
frame = pd.DataFrame(rows).sort_values(["region", "name"]).reset_index(drop=True)
frame.groupby("region").size().rename("countries")
Resolve a selector¶
resolve_iso2 accepts a bare ISO2 code, a country: selector, or a friendly country name — and passes through any well-formed alpha-2 code even if it is not curated.
In [ ]:
Copied!
print(catalog.resolve_iso2("KE")) # bare code
print(catalog.resolve_iso2("Kenya")) # friendly name
print(catalog.resolve_iso2("country:BR")) # country: selector
print(catalog.resolve_iso2("ZW")) # uncatalogued, still valid
print(catalog.resolve_iso2("KE")) # bare code
print(catalog.resolve_iso2("Kenya")) # friendly name
print(catalog.resolve_iso2("country:BR")) # country: selector
print(catalog.resolve_iso2("ZW")) # uncatalogued, still valid
Validate the catalog¶
earthlens datasets validate iucn
With an IUCN_TOKEN set, the quickstart fetches a species' assessments, and the country breakdown summarises a country's Red List.