IUCN — a country's Red List breakdown¶
Pull every assessment for a country and summarise it by Red List category, then chart how many species sit in each threat class. Builds on the quickstart by aggregating a country query.
Token. Needs a Red List v4 token in
IUCN_TOKEN(https://api.iucnredlist.org/users/sign_up). See Authentication.
Setup¶
In [ ]:
Copied!
import matplotlib.pyplot as plt
from earthlens import EarthLens
import matplotlib.pyplot as plt
from earthlens import EarthLens
Fetch a country's assessments¶
variables=["country:KE"] (or a friendly name like "Kenya") lists every assessment IUCN holds for the country.
In [ ]:
Copied!
frame = EarthLens(
data_source="iucn",
variables=["country:KE"],
start="2024-01-01",
end="2024-12-31",
lat_lim=[-90.0, 90.0],
lon_lim=[-180.0, 180.0],
path="out/iucn",
).download()
print(f"{len(frame)} assessments")
frame.head()
frame = EarthLens(
data_source="iucn",
variables=["country:KE"],
start="2024-01-01",
end="2024-12-31",
lat_lim=[-90.0, 90.0],
lon_lim=[-180.0, 180.0],
path="out/iucn",
).download()
print(f"{len(frame)} assessments")
frame.head()
Breakdown by Red List category¶
The category column holds the code (LC, NT, VU, EN, CR, …).
In [ ]:
Copied!
by_category = frame["category"].value_counts()
by_category
by_category = frame["category"].value_counts()
by_category
Chart the threat profile¶
In [ ]:
Copied!
order = ["LC", "NT", "VU", "EN", "CR", "EW", "EX", "DD"]
counts = by_category.reindex([c for c in order if c in by_category.index])
ax = counts.plot(kind="bar", color="firebrick")
ax.set_title("Kenya — assessments by Red List category")
ax.set_xlabel("category")
ax.set_ylabel("species")
plt.show()
order = ["LC", "NT", "VU", "EN", "CR", "EW", "EX", "DD"]
counts = by_category.reindex([c for c in order if c in by_category.index])
ax = counts.plot(kind="bar", color="firebrick")
ax.set_title("Kenya — assessments by Red List category")
ax.set_xlabel("category")
ax.set_ylabel("species")
plt.show()
Licensing¶
Red List data is CC-BY-NC and may not be redistributed without a written IUCN waiver, so every download raises a LicenseWarning.