Python API

get_token

get_token(key='WDPA_KEY')[source]

Check Protected Planet API token.

This function checks if the user has stored a valid Protected Planet API token as an environment variable file under the key "WDPA_KEY".

Before using this package for the first time, the user must follow these steps:

  1. Fill in the form available at https://api.protectedplanet.net/request to obtain a personal API token.

  2. Store the token as an environment variable under the key “WDPA_KEY”. You can use the command os.environ["WDPA_KEY"]="your_token" or python-dotenv: https://github.com/theskumar/python-dotenv.

Parameters

key – Environment variable name (recommended name: "WDPA_KEY").

Returns

A vector of length one with the value of the API token.

get_wdpa

get_wdpa(iso3, output_dir='.')[source]

This function downloads protected areas for one country using the WDPA API. Protected areas defined by a point are not considered. The shapefile is written on the hard drive (in the current directory).

Parameters
  • iso3 – The ISO-3 code of the country.

  • output_dir – Directory used for download.