Cfo Api

Python wrappers for accessing Forest Observatory data via the Salo API
Alternatives To Cfo Api
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Scidb Py112
7 days ago11otherPython
Python wrapper for SciDB queries
Py Oauth2102719 years ago10August 10, 20141Python
A Python wrapper for the OAuth 2.0 specification
Postcard_creator_wrapper48117 days ago26August 12, 20235apache-2.0Python
A python wrapper around the Rest API of the Swiss Postcard creator :postbox:
Metabase Py4223 years ago19April 26, 2021mitPython
python wrapper for metabase api
Graphcommons Python27
44 years ago2September 11, 20154mitPython
Python Wrapper For Graph Commons API.
Yandex Disk Webdav23
12 years ago2January 13, 2014mitPython
Python wrapper to work with yandex disk using webdav Basic Auth
10 years agoPython
A python wrapper for the Jawbone UP API
Khan Api Python9
8 years agoPython
Python wrapper for Khan Academy API
Mojang Api9
6 years ago1mitPython
A full Python wrapper of Mojang's API and Authentication API.
8 years agomitPython
Python wrapper for the Travis-CI API and set of scripts to manage travis information
Alternatives To Cfo Api
Select To Compare

Alternative Project Comparisons
California Forest Observatory


The California Forest Observatory (CFO) is a data-driven forest monitoring system that maps the drivers of wildfire behavior across the state—including vegetation fuels, weather, topography & infrastructure—from space.

The cfo library was designed to provide easy access to CFO datasets. Each dataset has a unique asset_id, and the search and fetch workflows were designed to query and download these assets.

  • You can search for asset IDs by geography, data type, and time of year
    •"SantaCruzCounty", metric="CanopyHeight", year=2020)
  • You can download the data to your loacal machine
    •, output_file)
  • If you don't want the file, you can just fetch the download URL
    • forest.fetch(asset_id, dl=True)
  • Or a WMS URL for web mapping
    • forest.fetch(asset_id, wms=True)

You can find support for the CFO API at the community forum.


CFO data are available for free for non-commercial use per the API terms. You must have a CFO account, which you can create by visiting the web map, clicking the menu in the top right corner and selecting "Create an account." Please keep track of the e-mail address and password you used to create your Forest Observatory account, as you'll need them to authenticate API access.

The software provided here, the cfo python API wrapper, is provided with an MIT license. Please do not confuse the license terms for the wrapper with the terms of use for the API.

Table of contents


This library can be installed via pip directly from Github.

pip install cfo

If you don't have pip you could also clone the repository locally and install using python's setuptools

git clone
cd cfo-api
python install

Once installed, you should be able to load the cfo module in python. Instatiate the api class to begin working with the Forest Observatory API.

import cfo
forest = cfo.api()
Canopy Height


A Forest Observatory account is required to use the API (sign up free at

There are two authentication methods: entering your CFO account's email/password at runtime or setting environment variables.

Passing your credentials at runtime

Using any API call (, forest.fetch(), will prompt you to enter the following authentication information:

>>> CFO E-mail: [email protected]
>>> CFO Password: **********

You can also authenticate directly with forest.authenticate().

This retrieves an authentication token from the API, which is stored as a temp file for future access (this does not store your e-mail/password). The API reads this stored token, which means you won't have to pass your email/password during each session.

Setting environment variables

You can forego runtime credential entry by setting environment variables. This is the lowest friction, least secure approach. You'll set the following variables in your .bashrc profile or elsewhere.

export [email protected]
export CFO_PASS=ari0limax

Restoring a botched authentication

The temp file that stores your authentication credentials can sometimes get donked up. To re-authenticate, use the following command to pass your credentials and overwrite the temporary token data.

Spotting during the Rough Fire


CFO data are organized by asset_id. These IDs contain information on the spatial extent of the data, the category and name of the data, the time of collection, and the spatial resolution. Asset IDs follow this naming format:

asset_id = {geography}-{category}-{metric}-{year}-{timeOfYear}-{resolution}

Some examples:

  • A statewide vegetation fuels dateset that's rendered in the Layers tab: California-Vegetation-CanopyHeight-2020-Summer-00010m.
  • A statewide weather dataset queried in the Trends tab: California-Weather-WindSpeed-2020-0601-03000m.
  • A county-level dataset accessed in the Download tab: Marin-Vegetation-SurfaceFuels-2020-Spring-00010m.

The function queries the API and returns the assets that match the search terms.

>>> import cfo
>>> forest = cfo.api()
>>>"MendocinoCounty", metric="CanopyCover")
2020-09-07 13:53:47,028 INFO cfo.utils [authenticate] Loaded cfo token

The default behavior of this function is to return the asset IDs as a list.

You could instead return the API JSON data, including asset ID, the spatial extent (bbox) of the data, the catalog its stored in, etc. by setting just_assets=False.

>>>"MendocinoCounty", metric="CanopyCover", just_assets=False)
[{'asset_id': 'MendocinoCounty-Vegetation-CanopyCover-2020-Fall-00010m',
'attribute_dict': {},
'bbox': [-124.022978699284, -122.814767867036, 38.7548320538975, 40.0060478879686],
'catalog': 'cfo',
'description': 'CanopyCover',
'expiration_utc_datetime': '',
'utc_datetime': '2020-07-09 09:52:42.292286+00:00'}]

And to examine the full response from the requests library, use

But with over 17,000 published assets it's not easy to know just what to search by. So we wrote some functions to simplify your searches.

Convenience functions

Based on the asset ID naming convention above, we've provided some list functions as a guide to what's available.

  • Geography - CFO datasets have been clipped to different spatial extents: statewide, by county, by municipality, by watershed.
    • forest.list_geographies() - returns the different geographic extents. Use forest.list_geographies(by="County") to narrow return just the unique counties.
    • forest.list_geography_types() - returns the categories of geographical clipping available.
  • Category - we currently provide three categories of data.
    • forest.list_categories() - returns [Vegetation, Weather, Wildfire]
  • Metric - each category of data contains a list of different available data types
    • forest.list_metrics() - returns the unique metrics for each category.
    • Run forest.list_metrics(category="Weather") to return only weather-specific metrics.

Use these as keywords when searching for data (e.g. id_list ="FresnoCounty", category="Vegetation")).

You can also use wildcards:

>>>'Plumas*', metric='CanopyHeight')

A note on availabile datasets

Even though we have a range of geographic extents, resolutions, and metrics, it is not the case that we provide all permutations of extent/resolution/metric. For example, we clip all Vegetation data to the county level, but we do not clip any Weather data that fine. All weather data are only available at the state level.

This means you don't really need to specify the geographic extent if you search for weather data. You'll get pretty far with wind_ids ="WindSpeed").

Redwood understory


Once you've generated a list of asset IDs, you can then download the files to your local machine. The function requires an asset_id string so you'll have to iterate over search results, which are often returned as lists.

Here's how to search for and download all data from Mendocino County.

import cfo
forest = cfo.api()
asset_ids ="MendocinoCounty")
for asset in asset_ids:

Which generates the following output as it downloads each file.

2020-09-07 16:19:24,542 INFO cfo.utils [download] Beginning download for: MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m
2020-09-07 16:19:28,853 INFO cfo.utils [download] Successfully downloaded MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m to file: /home/slug/MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m.tif
2020-09-07 16:19:29,359 INFO cfo.utils [download] Beginning download for: MendocinoCounty-Vegetation-CanopyBaseHeight-2020-Fall-00010m
2020-09-07 16:19:32,321 INFO cfo.utils [download] Successfully downloaded MendocinoCounty-Vegetation-CanopyBaseHeight-2020-Fall-00010m to file: /home/slug/MendocinoCounty-Vegetation-CanopyBaseHeight-2020-Fall-00010m.tif

This function uses the fetch() command under the hood to retrieve a URL for where the file is hosted on google cloud storage. It then performs a GET call to download the file locally.

The function will download the file to your current working directory if you don't specify an output file path. You can set a custom output path with, path). This may be tricky if you're downloading multiple datasets, but you could parse the asset_id to generate useful names for output files.

asset_ids ="MendocinoCounty")
for asset in asset_ids:
    geo, category, metric, year, timeOfYear, res = asset.split("-")
    output_path = f"/external/downloads/CFO-{metric}-{year}.tif", output_path)

Which generates the following output:

2020-09-07 23:10:02,312 INFO cfo.utils [download] Beginning download for: MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m
2020-09-07 23:10:25,163 INFO cfo.utils [download] Successfully downloaded MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m to file: /external/downloads/CFO-CanopyHeight-2020.tif
2020-09-07 23:10:25,596 INFO cfo.utils [download] Beginning download for: MendocinoCounty-Vegetation-CanopyBaseHeight-2020-Fall-00010m
2020-09-07 23:10:47,965 INFO cfo.utils [download] Successfully downloaded MendocinoCounty-Vegetation-CanopyBaseHeight-2020-Fall-00010m to file: /external/downloads/CFO-CanopyBaseHeight-2020.tif
Mono Lake

Map tiles

The fetch function also returns URLs for displaying CFO data in web mapping applications as WMS tile layers.

forest.fetch("MendocinoCounty-Vegetation-CanopyHeight-2020-Fall-00010m", wms=True)

WMS URLs don't always easily plug and play with different rendering services, but they should work with a little nudging. Here's how to use the above URL to visualize these data in a jupyter notebook with ipyleaflet.

from ipyleaflet import Map, WMSLayer, LayersControl, basemaps
wms = WMSLayer(
    name="Mendocino Canopy Height",
    attribution="Forest Observatory © <a href='>Salo Sciences</a>",
m = Map(basemap=basemaps.Stamen.Terrain, center=(39.39,-123.33), zoom=10)
control = LayersControl(position='topright')

This code, executed in jupyter-lab, should look something like this.

CFO WMS example

The URL has a lot of useful information. Here's a quick breakdown of what's encoded in the string returned from fetch.

  • The base URL ( is our map server address.
  • Each component following the ? is a parameter passed to the map server.
  • layers specifies which asset to show (and is defined based on {catalog}:{asset_id} naming).
  • format defines the image format the data are rendered in (use image/png8 for best performance).
  • styles defines the color palette (which you can retrieve with forest.list_styles()).
  • the long list of p0, p2, p25, ..., p100 are parameters we use to render custom raster styles on the fly. These numbers are based on the min/max raster values of a dataset and can be altered on the fly to dynamically scale the data.


Issue tracking isn't set up for this repository yet. Please visit the Forest Observatory Community Forum for technical support. To get in touch directly or to inquire about commercial API access, contact [email protected].

The California Forest Observatory API is developed and maintained by Salo Sciences.

Popular Python Wrapper Projects
Popular Authentication Projects
Popular Application Programming Interfaces Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python Wrapper