WDPA quickstart — protected-area polygons for a country¶
Fetch a country's protected areas from Protected Planet (WDPA) through the EarthLens facade, then map the polygons.
WDPA is the cluster's polygon backend: download() returns a FeatureCollection of Polygon / MultiPolygon geometries in EPSG:4326, fetched from the Protected Planet v4 REST API.
Token. Protected Planet v4 needs a personal token (request one at https://api.protectedplanet.net/request). Set it as the
WDPA_TOKENenvironment variable. The backend uses corerequests— there is no SDK extra to install.
Setup¶
Import matplotlib for the map and the EarthLens entry point. The WDPA_TOKEN environment variable supplies the credential.
import matplotlib.pyplot as plt
from earthlens import EarthLens
Request parameters¶
variables=["KEN"] selects Kenya by ISO3 code; you can also pass a friendly name ("Kenya"), a "country:KEN" selector, or a numeric WDPA id. WDPA is not time-filtered, so the dates only frame the request.
country = ["KEN"]
start, end = "2024-01-01", "2024-12-31"
Download¶
Reads WDPA_TOKEN from the environment. One call returns the protected-area polygons and writes a GeoParquet under path.
fc = EarthLens(
data_source="wdpa",
variables=country,
start=start,
end=end,
lat_lim=[-90.0, 90.0],
lon_lim=[-180.0, 180.0],
path="out/wdpa",
).download()
print(f"{len(fc)} protected areas")
fc[["name", "designation", "iucn_category"]].head()
Map the protected areas¶
ax = fc.plot(facecolor="forestgreen", edgecolor="black", alpha=0.5)
ax.set_title("WDPA protected areas — Kenya")
ax.set_xlabel("longitude")
ax.set_ylabel("latitude")
plt.show()
Licensing¶
WDPA carries a custom UNEP-WCMC license (not Creative Commons): commercial use needs written permission and redistribution is restricted, so every download raises a LicenseWarning. Cite the database as the Protected Planet terms require.