WDPA catalog explorer (no network)¶
Browse the curated WDPA country catalog and the selector resolution — entirely offline, with no token and no API call. This is the quickest way to see which countries ship as friendly entries and how a variables selector becomes the ISO3 code the Protected Planet v4 country= filter expects.
Load the catalog¶
In [ ]:
Copied!
import pandas as pd
from earthlens.wdpa import Catalog
catalog = Catalog()
print(f"{len(catalog)} curated countries")
import pandas as pd
from earthlens.wdpa import Catalog
catalog = Catalog()
print(f"{len(catalog)} curated countries")
The curated countries, by region¶
Each row is keyed by its ISO3 code; the catalog is a convenience subset across every continent.
In [ ]:
Copied!
rows = [
{"iso3": 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 = [
{"iso3": 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_iso3 accepts a bare ISO3 code, a country: selector, or a friendly country name — and passes through any well-formed alpha-3 code even if it is not curated.
In [ ]:
Copied!
print(catalog.resolve_iso3("KEN")) # bare code
print(catalog.resolve_iso3("Kenya")) # friendly name
print(catalog.resolve_iso3("country:BRA")) # country: selector
print(catalog.resolve_iso3("ZWE")) # uncatalogued, still valid
print(catalog.resolve_iso3("KEN")) # bare code
print(catalog.resolve_iso3("Kenya")) # friendly name
print(catalog.resolve_iso3("country:BRA")) # country: selector
print(catalog.resolve_iso3("ZWE")) # uncatalogued, still valid
Validate the catalog¶
The curated entries are linted by the CLI (offline, no network):
earthlens datasets validate wdpa
With a WDPA_TOKEN set, the quickstart fetches a country's protected-area polygons.