File Input/Output utilities.


Bases: object

Data storage and retrieval functionality for Earthlab.

An object of this class is available upon importing earthpy as that writes data files to the path: ~/earth-analytics/data/.

Parameters:path (string | None) – The path where data is stored. NOTE: this defaults to the directory ~/earth-analytics/data/.


List datasets that are available for download, using default object:

>>> import earthpy as et
Available Datasets: ['california-rim-fire', ...]

Specify a custom directory for data downloads:

>>> = "."
Available Datasets: ['california-rim-fire', ...]
get_data(key=None, url=None, replace=False, verbose=True)[source]

Retrieve the data for a given week and return its path.

This will retrieve data from the internet if it isn’t already downloaded, otherwise it will only return a path to that dataset.

  • key (str) – The dataset to retrieve. Possible options can be found in self.data_keys. Note: key and url are mutually exclusive.
  • url (str) – A URL to fetch into the data directory. Use this for ad-hoc dataset downloads. Note: key and url are mutually exclusive.
  • replace (bool) – Whether to replace the data for this key if it is already downloaded.
  • verbose (bool) – Whether to print verbose output while downloading files.

path_data – The path to the downloaded data.

Return type:



Download a dataset using a key:

>>>'california-rim-fire') # doctest: +SKIP

Or, download a dataset using a figshare URL:

>>> url = ''
>>>  # doctest: +SKIP[source]

Construct a file path to an example dataset.

This file defines helper functions to access data files in this directory, to support examples. Adapted from the PySAL package.

Parameters:dataset (string) – Name of a dataset to access (e.g., “epsg.json”, or “RGB.byte.tif”)
Return type:A file path (string) to the dataset


>>> import as eio
>>> eio.path_to_example('rmnp-dem.tif')