# Import the following libraries
import requests
import folium
import folium.plugins
from folium import Map, TileLayer
from pystac_client import Client
import branca
import pandas as pd
import matplotlib.pyplot as plt
Utilizing the Air-Sea CO₂ Flux ECCO-Darwin Model to Visualize CO₂ Exchange and Dynamics Between the Atmosphere and the Ocean
Access this Notebook
You can launch this notebook in the US GHG Center JupyterHub by clicking the link below. If you are a new user, you should first sign up for the hub by filling out this request form and providing the required information.
Access the Air-Sea CO₂ Flux, ECCO-Darwin Model notebook in the US GHG Center JupyterHub.
Table of Contents
Data Summary and Application
- Spatial coverage: Global
- Spatial resolution: 1/3°
- Temporal extent: January 2020 - December 2022
- Temporal resolution: Monthly
- Unit: Millimoles of CO₂ per meter squared per second
- Utility: Climate Research, Oceanography, Carbon Stock Monitoring
For more, visit the Air-Sea CO₂ Flux ECCO-Darwin Model data overview page.
Approach
- Identify available dates and temporal frequency of observations for the given collection using the GHGC API
/stac
endpoint. The collection processed in this notebook is the Air-Sea CO₂ Flux, ECCO-Darwin Model v5 Data product. - Pass the STAC item into the raster API
/collections/{collection_id}/items/{item_id}/tilejson.json
endpoint. - Using
folium.plugins.DualMap
, we will visualize two tiles (side-by-side), allowing us to compare time points. - After the visualization, we will perform zonal statistics for a given polygon.
About the Data
The ocean is a major sink for atmospheric carbon dioxide (CO₂), largely due to the presence of phytoplankton that use the CO₂ to grow. Studies have shown that global ocean CO₂ uptake has increased over recent decades, however, there is uncertainty in the various mechanisms that affect ocean CO₂ flux and storage and how the ocean carbon sink will respond to future climate change.
Because CO₂ fluxes can vary significantly across space and time, combined with deficiencies in ocean and atmosphere CO₂ observations, there is a need for models that can thoroughly represent these processes. Ocean biogeochemical models (OBMs) can resolve the physical and biogeochemical mechanisms contributing to spatial and temporal variations in air-sea CO₂ fluxes but previous OBMs do not integrate observations to improve model accuracy and have not been able to operate on the seasonal and multi-decadal timescales needed to adequately characterize these processes.
The ECCO-Darwin model is an OBM that assimilates Estimating the Circulation and Climate of the Ocean (ECCO) consortium ocean circulation estimates and biogeochemical processes from the Massachusetts Institute of Technology (MIT) Darwin Project. A pilot study using ECCO-Darwin was completed by Brix et al. (2015) however, an improved version of the model was developed by Carroll et al. (2020) in which issues present in the first model were addressed using data assimilation and adjustments were made to initial conditions and biogeochemical parameters. The updated ECCO-Darwin model was compared with interpolation-based products to estimate surface ocean partial pressure (pCO2) and air-sea CO₂ flux. This dataset contains the gridded global, monthly mean air-sea CO₂ fluxes from version 5 of the ECCO-Darwin model.
The data available in the US GHG Center hub are available at ~1/3° horizontal resolution at the equator (~18 km at high latitudes) from January 2020 through December 2022. For more information regarding this dataset, please visit the Air-Sea CO₂ Flux ECCO-Darwin Model data overview page.
Install the Required Libraries
Required libraries are pre-installed on the GHG Center Hub, except the tabulate
library. If you need to run this notebook elsewhere, please install the libraries by running the following command line:
%pip install requests folium rasterstats pystac_client pandas matplotlib tabulate –quiet
# Provide the STAC and RASTER API endpoints
# The endpoint is referring to a location within the API that executes a request on a data collection nesting on the server.
# The STAC API is a catalog of all the existing data collections that are stored in the GHG Center.
= "https://earth.gov/ghgcenter/api/stac"
STAC_API_URL
# The RASTER API is used to fetch collections for visualization
= "https://earth.gov/ghgcenter/api/raster"
RASTER_API_URL
# The collection name is used to fetch the dataset from the STAC API. First, we define the collection name as a variable
# Name of the collection for ECCO Darwin CO₂ flux monthly emissions
= "eccodarwin-co2flux-monthgrid-v5" collection_name
# Fetch the collection from the STAC API using the appropriate endpoint
# The 'requests' library allows a HTTP request possible
= requests.get(f"{STAC_API_URL}/collections/{collection_name}").json()
collection
# Print the properties of the collection to the console
collection
{'id': 'eccodarwin-co2flux-monthgrid-v5',
'type': 'Collection',
'links': [{'rel': 'items',
'type': 'application/geo+json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5/items'},
{'rel': 'parent',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/'},
{'rel': 'root',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/'},
{'rel': 'self',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5'}],
'title': 'Air-Sea CO₂ Flux, ECCO-Darwin Model v5',
'extent': {'spatial': {'bbox': [[-180.0, -90.0, 180.0, 90.0]]},
'temporal': {'interval': [['2020-01-01T00:00:00+00:00',
'2022-12-31T00:00:00+00:00']]}},
'license': 'CC-BY-4.0',
'renders': {'co2': {'assets': ['co2'],
'nodata': 'nan',
'rescale': [[-0.0007, 0.0002]],
'colormap_name': 'bwr'},
'dashboard': {'assets': ['co2'],
'nodata': 'nan',
'rescale': [[-0.0007, 0.0002]],
'colormap_name': 'bwr'}},
'summaries': {'datetime': ['2020-01-01T00:00:00Z', '2022-12-31T00:00:00Z']},
'description': 'Global, monthly average air-sea CO₂ flux (negative into ocean) at ~1/3° resolution from 2020 to 2022. Data are in units of millimoles of CO₂ per meter squared per second (mmol m²/s). Derived using the ECCO-Darwin model v5, which is an ocean biogeochemical model that assimilates Estimating the Circulation and Climate of the Ocean (ECCO) consortium ocean circulation estimates and biogeochemical processes from the Massachusetts Institute of Technology (MIT) Darwin Project.',
'item_assets': {'co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
'roles': ['data', 'layer'],
'title': 'Air-Sea CO₂ Flux',
'description': 'Monthly mean air-sea CO₂ flux (negative into ocean).'}},
'stac_version': '1.0.0',
'stac_extensions': ['https://stac-extensions.github.io/render/v1.0.0/schema.json',
'https://stac-extensions.github.io/item-assets/v1.0.0/schema.json'],
'dashboard:is_periodic': True,
'dashboard:time_density': 'month'}
Query the STAC API
First, you need to import the required libraries. Once imported, they allow better execution of a query in the GHG Center Spatio Temporal Asset Catalog (STAC) Application Programming Interface (API) where the granules for this collection are stored. You will learn the functionality of each library throughout the notebook.
# Provide the STAC and RASTER API endpoints
# The endpoint refers to a location within the API that executes a request on a data collection nesting on the server.
# The STAC API is a catalog of all the existing data collections stored in the GHG Center.
= "https://earth.gov/ghgcenter/api/stac/"
STAC_API_URL
# The RASTER API is used to fetch collections for visualization.
= "https://earth.gov/ghgcenter/api/raster/" RASTER_API_URL
STAC API Collection Names
Now, you must fetch the dataset from the STAC API by defining its associated STAC API collection ID as a variable. The collection ID, also known as the collection name, for the Air-Sea CO₂ Flux ECCO-Darwin Model dataset is eccodarwin-co2flux-monthgrid-v5
# The collection name is used to fetch the dataset from the STAC API. First, you must define the collection name as a variable.
# The collection name in the STAC API
= "eccodarwin-co2flux-monthgrid-v5"
collection_name
# Fetch the collection from the STAC API using the appropriate endpoint
# The 'requests' library allows a HTTP request possible
= requests.get(f"{STAC_API_URL}/collections/{collection_name}").json()
collection
# Print the properties of the collection in a table
# Adjust display settings
'display.max_colwidth', None) # Set maximum column width to "None" to prevent cutting off text
pd.set_option(
# Extract the relevant information about the collection
= {
collection_info "Title": collection.get("title", "N/A"), # Extract the title of the collection
"Description": collection.get("description", "N/A"), # Extract the dataset description
"Temporal Extent": collection.get("extent", {}).get("temporal", {}).get("interval", "N/A"), # Extract the temporal coverage of the collection
"Spatial Extent": collection.get("extent", {}).get("spatial", {}).get("bbox", "N/A"), # Extract the spatial coverage of the collection
}
# Convert the derived information into a DataFrame format
= pd.DataFrame(list(collection_info.items()), columns=["Collection Summary", ""])
properties_table
# Display the properties in a table
= properties_table.style.set_properties(**{'text-align': 'left'}) \
collection_summary
.set_table_styles([
{'selector': 'th.col0, td.col0', # Select the first column
'props': [('min-width', '200px'), # Set a minimum width
'text-align', 'left')] # Align text to the left
(
},
{'selector': 'td.col1', # Select the second column
'props': [('text-align', 'left')] # Align text to the left
}
])
# Print the collection summary table
collection_summary
Next, you will examine the contents of the collection
under the temporal
variable. You’ll see that the data is available from January 2020 to December 2022. Looking at the dashboard:time density
, you can observe that the data is periodic with monthly time density.
# Create a function that would search for data collection in the US GHG Center STAC API
# First, we need to define the function
# The name of the function is "get_item_count"
# The argument that will be passed to the defined function is "collection_id"
def get_item_count(collection_id):
# Set a counter for the number of items existing in the collection
= 0
count
# Define the path to retrieve the granules (items) of the collection of interest in the STAC API
= f"{STAC_API_URL}/collections/{collection_id}/items"
items_url
# Run a while loop to make HTTP requests until there are no more URLs associated with the collection in the STAC API
while True:
# Retrieve information about the granules by sending a "get" request to the STAC API using the defined collection path
= requests.get(items_url)
response
# If the items do not exist, print an error message and quit the loop
if not response.ok:
print("error getting items")
exit()
# Return the results of the HTTP response as JSON
= response.json()
stac
# Increase the "count" by the number of items (granules) returned in the response
+= int(stac["context"].get("returned", 0))
count
# Retrieve information about the next URL associated with the collection in the STAC API (if applicable)
next = [link for link in stac["links"] if link["rel"] == "next"]
# Exit the loop if there are no other URLs
if not next:
break
# Ensure the information gathered by other STAC API links associated with the collection are added to the original path
# "href" is the identifier for each of the tiles stored in the STAC API
= next[0]["href"]
items_url
# Return the information about the total number of granules found associated with the collection
return count
# Apply the function created above "get_item_count" to the Air-Sea CO2 Flux ECCO-Darwin collection
= get_item_count(collection_name)
number_of_items
# Get the information about the number of granules found in the collection
= requests.get(f"{STAC_API_URL}/collections/{collection_name}/items?limit={number_of_items}").json()["features"]
items
# Print the total number of items (granules) found
print(f"Found {len(items)} observations")
# Sort the items based on their date-time attribute
= sorted(items, key=lambda x: x["properties"]["start_datetime"])
items_sorted
# Create an empty list
= []
table_data # Extract the ID and date-time information for each granule and add them to the list
# By default, only the first 5 items in the collection are extracted to be displayed in the table.
# To see the date-time of all existing granules in this collection, remove "5" from "item_sorted[:5]" in the line below.
for item in items_sorted[:5]:
'id'], item['properties']['start_datetime']])
table_data.append([item[
# Define the table headers
= ["Item ID", "Start Date-Time"]
headers
print("Below you see the first 5 items in the collection, along with their item IDs and corresponding Start Date-Time.")
# Print the table using tabulate
print(tabulate(table_data, headers=headers, tablefmt="fancy_grid"))
Found 36 items
# Examine the first item in the collection
# Keep in mind that a list starts from 0, 1, 2... therefore items[0] refers to the first item (granule) in the list/collection
0] items_sorted[
{'id': 'eccodarwin-co2flux-monthgrid-v5-202212',
'bbox': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'type': 'Feature',
'links': [{'rel': 'collection',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5'},
{'rel': 'parent',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5'},
{'rel': 'root',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/'},
{'rel': 'self',
'type': 'application/geo+json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212'},
{'title': 'Map of Item',
'href': 'https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/map?assets=co2&nodata=nan&rescale=-0.0007%2C0.0002&colormap_name=bwr',
'rel': 'preview',
'type': 'text/html'}],
'assets': {'co2': {'href': 's3://ghgc-data-store/eccodarwin-co2flux-monthgrid-v5/ECCO-Darwin_CO2_flux_202212.tif',
'type': 'image/tiff; application=geotiff',
'roles': ['data', 'layer'],
'title': 'Air-Sea CO₂ Flux',
'proj:bbox': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'proj:epsg': 4326.0,
'proj:shape': [721.0, 1440.0],
'description': 'Monthly mean air-sea CO₂ flux (negative into ocean).',
'raster:bands': [{'scale': 1.0,
'offset': 0.0,
'sampling': 'area',
'data_type': 'float64',
'histogram': {'max': 1e+20,
'min': -0.0560546528687938,
'count': 11.0,
'buckets': [338606.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 186706.0]},
'statistics': {'mean': 3.554192556042885e+19,
'stddev': 4.786401658343999e+19,
'maximum': 1e+20,
'minimum': -0.0560546528687938,
'valid_percent': 0.0001903630604288499}}],
'proj:geometry': {'type': 'Polygon',
'coordinates': [[[-180.125, -90.124826629681],
[179.875, -90.124826629681],
[179.875, 89.875173370319],
[-180.125, 89.875173370319],
[-180.125, -90.124826629681]]]},
'proj:projjson': {'id': {'code': 4326.0, 'authority': 'EPSG'},
'name': 'WGS 84',
'type': 'GeographicCRS',
'datum': {'name': 'World Geodetic System 1984',
'type': 'GeodeticReferenceFrame',
'ellipsoid': {'name': 'WGS 84',
'semi_major_axis': 6378137.0,
'inverse_flattening': 298.257223563}},
'$schema': 'https://proj.org/schemas/v0.4/projjson.schema.json',
'coordinate_system': {'axis': [{'name': 'Geodetic latitude',
'unit': 'degree',
'direction': 'north',
'abbreviation': 'Lat'},
{'name': 'Geodetic longitude',
'unit': 'degree',
'direction': 'east',
'abbreviation': 'Lon'}],
'subtype': 'ellipsoidal'}},
'proj:transform': [0.25,
0.0,
-180.125,
0.0,
-0.24965325936199723,
89.875173370319,
0.0,
0.0,
1.0]},
'rendered_preview': {'title': 'Rendered preview',
'href': 'https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/preview.png?assets=co2&nodata=nan&rescale=-0.0007%2C0.0002&colormap_name=bwr',
'rel': 'preview',
'roles': ['overview'],
'type': 'image/png'}},
'geometry': {'type': 'Polygon',
'coordinates': [[[-180.125, -90.124826629681],
[179.875, -90.124826629681],
[179.875, 89.875173370319],
[-180.125, 89.875173370319],
[-180.125, -90.124826629681]]]},
'collection': 'eccodarwin-co2flux-monthgrid-v5',
'properties': {'end_datetime': '2022-12-31T00:00:00+00:00',
'start_datetime': '2022-12-01T00:00:00+00:00'},
'stac_version': '1.0.0',
'stac_extensions': ['https://stac-extensions.github.io/raster/v1.1.0/schema.json',
'https://stac-extensions.github.io/projection/v1.1.0/schema.json']}
Visual Comparison Across Time Periods
You will now explore changes in CO₂ flux at a given location and time. You will visualize the outputs on a map using folium
.
# Once again, apply the function created above "get_item_count" to the collection
# This step allows retrieving the number of granules “observations” in the collection.
= get_item_count(collection_name)
number_of_items = requests.get(f"{STAC_API_URL}/collections/{collection_name}/items?limit={number_of_items}").json()["features"]
items
# Now you need to create a dictionary where the start datetime values for each granule are queried more explicitly by year and month (e.g., 2020-02)
= {item["properties"]["start_datetime"]: item for item in items}
items
# Next, you need to specify the asset name for this collection.
# The asset name refers to the raster band containing the pixel values for the parameter of interest.
# For the case of this collection, the parameter of interest is “co2”.
= "co2" asset_name
Below, you will enter the minimum and maximum values to provide our upper and lower bounds in the rescale_values
.
# Fetch the minimum and maximum values for the CO2 value range
= {"max":0.0007, "min":-0.0007} rescale_values
Now, you will pass the item id, collection name, asset name, and the rescaling factor
to the Raster API
endpoint. This step is done twice so that you can visualize two arbitrary events independently.
# Choose a color map for displaying the first observation (event)
# Please refer to matplotlib library if you'd prefer to choose a different color ramp.
# For more information on Colormaps in Matplotlib, please visit https://matplotlib.org/stable/users/explain/colors/colormaps.html
= "magma"
color_map
# You can retrieve the first observation of interest by defining the last 6 digits of its Item ID.
# The numbers indicate the year and month (YYYYMM) when the data was gathered.
# For example, the observation collected in December 2022 has the following item ID: eccodarwin-co2flux-monthgrid-v5-202212
# To set the time, you will need to insert "202212" in the line below.
# Set the time
# If you want to select another time, you can refer to the Data Browser on the U.S. Greenhouse Gas Center website
# URL to the Air-Sea CO2 Flux ECCO-Darwin collection in the US GHG Center: https://dljsq618eotzp.cloudfront.net/browseui/#eccodarwin-co2flux-monthgrid-v5/
= '202212'
observation_date_1
# Don't change anything here
= f'eccodarwin-co2flux-monthgrid-v5-{observation_date_1}'
observation_1
# Make a GET request to retrieve information for the December 2022 tile
# A GET request is made for the December 2022 tile.
= requests.get(
december_2022_tile
# Pass the collection name, the item number in the list, and its ID
f"{RASTER_API_URL}/collections/{items[list(items.keys())[0]]['collection']}/items/{items[list(items.keys())[0]]['id']}/tilejson.json?"
# Pass the asset name
f"&assets={asset_name}"
# Pass the color formula and colormap for custom visualization
f"&color_formula=gamma+r+1.05&colormap_name={color_map}"
# Pass the minimum and maximum values for rescaling
f"&rescale={rescale_values['min']},{rescale_values['max']}"),
# Return the response in JSON format
).json()
# Print the properties of the retrieved granule to the console
december_2022_tile
{'tilejson': '2.2.0',
'version': '1.0.0',
'scheme': 'xyz',
'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2&color_formula=gamma+r+1.05&colormap_name=magma&rescale=-0.0007%2C0.0007'],
'minzoom': 0,
'maxzoom': 24,
'bounds': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'center': [-0.125, -0.1248266296809959, 0]}
# You will repeat the same approach used in the previous step to retrieve the second observation of interest
= '202104'
observation_date_2
# Don't change anything here
= f'eccodarwin-co2flux-monthgrid-v5-{observation_date_2}'
observation_2
# Make a GET request to retrieve information for the December 2022 tile
# A GET request is made for the April 2021 tile.
= requests.get(
april_2021_tile
# Pass the collection name, the item number in the list, and its ID
f"{RASTER_API_URL}/collections/{items[list(items.keys())[20]]['collection']}/items/{items[list(items.keys())[20]]['id']}/tilejson.json?"
# Pass the asset name
f"&assets={asset_name}"
# Pass the color formula and colormap for custom visualization
f"&color_formula=gamma+r+1.05&colormap_name={color_map}"
# Pass the minimum and maximum values for rescaling
f"&rescale={rescale_values['min']},{rescale_values['max']}"),
# Return the response in JSON format
).json()
# Print the properties of the retrieved granule to the console
april_2021_tile
{'tilejson': '2.2.0',
'version': '1.0.0',
'scheme': 'xyz',
'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202104/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2&color_formula=gamma+r+1.05&colormap_name=magma&rescale=-0.0007%2C0.0007'],
'minzoom': 0,
'maxzoom': 24,
'bounds': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'center': [-0.125, -0.1248266296809959, 0]}
Map Out Selected Tiles
For this study, you are going to compare the CO₂ levels along the coast of California.
# To change the location, you can simply insert the latitude and longitude of the area of your interest in the "location=(LAT, LONG)" statement
# Set the initial zoom level and center of map for both tiles
# 'folium.plugins' allows mapping side-by-side
= folium.plugins.DualMap(location=(34, -118), zoom_start=7)
map_
# Define the first map layer with the CO2 Flux data for December 2022
= TileLayer(
map_layer_1 =december_2022_tile["tiles"][0], # Path to retrieve the tile
tiles="GHG", # Set the attribution
attr='December 2022 CO2 Flux', # Title for the layer
name=True, # The layer can be overlaid on the map
overlay=0.8, # Adjust the transparency of the layer
opacity
)# Add the first layer to the Dual Map
map_layer_1.add_to(map_.m1)
# Define the second map layer with the CO2 Flux data for April 2021
= TileLayer(
map_layer_2 =april_2021_tile["tiles"][0], # Path to retrieve the tile
tiles="GHG", # Set the attribution
attr='April 2021 CO2 Flux', # Title for the layer
name=True, # The layer can be overlaid on the map
overlay=0.8, # Adjust the transparency of the layer
opacity
)# Add the second layer to the Dual Map
map_layer_2.add_to(map_.m2)
# Display data markers (titles) on both maps
40, 5.0), tooltip="both").add_to(map_)
folium.Marker((
# Add a layer control to switch between map layers
=False).add_to(map_)
folium.LayerControl(collapsed
# Add a legend to the dual map using the 'branca' library
# Note: the inserted legend is representing the minimum and maximum values for both tiles
# Minimum value = -0.0007, maximum value = 0.0007
= branca.colormap.LinearColormap(colors=["#0000FF", "#3399FF", "#66CCFF", "#FFFFFF", "#FF66CC", "#FF3399", "#FF0000"], vmin=-0.0007, vmax=0.0007)
colormap
# Add the data unit as caption
= 'Millimoles per meter squared per second (mmol m²/s)'
colormap.caption
# Define custom tick values for the legend bar
= [-0.0007, -0.00035, 0, 0.00035, 0.0007]
tick_val
# Create a HTML representation
= colormap._repr_html_()
legend_html
# Create a customized HTML structure for the legend
= f'''
legend_html <div style="position: fixed; bottom: 50px; left: 50px; z-index: 1000; width: 400px; height: auto; background-color: rgba(255, 255, 255, 0.8);
border-radius: 5px; border: 1px solid grey; padding: 10px; font-size: 14px; color: black;">
<b>{colormap.caption}</b><br>
<div style="display: flex; justify-content: space-between;">
<div>{tick_val[0]}</div>
<div>{tick_val[1]}</div>
<div>{tick_val[2]}</div>
<div>{tick_val[3]}</div>
<div>{tick_val[4]}</div>
</div>
<div style="background: linear-gradient(to right,
{'#0000FF'}, {'#3399FF'} {20}%,
{'#3399FF'} {20}%, {'#66CCFF'} {40}%,
{'#66CCFF'} {40}%, {'#FFFFFF'} {50}%,
{'#FFFFFF'} {50}%, {'#FF66CC'} {80}%,
{'#FF66CC'} {80}%, {'#FF3399'}); height: 10px;"></div>
</div>
'''
# Display the legend and caption on the map
map_.get_root().html.add_child(folium.Element(legend_html))
# Visualize the Dual Map
map_
Calculate Zonal Statistics
To perform zonal statistics, you first need to create a polygon. In this use case, you are creating a polygon along the coast of California, United States.
# Create a polygon for the area of interest (aoi)
= {
california_coast_aoi "type": "Feature", # Create a feature object
"properties": {},
"geometry": { # Set the bounding coordinates for the polygon
"coordinates": [
[-124.19, 37.86], # North-west bounding coordinate
[-123.11, 37.86], # North-east bounding coordinate
[-119.96, 33.16], # South-east bounding coordinate
[-121.13, 33.16], # South-west bounding coordinate
[-124.19, 37.86] # North-west bounding coordinate (closing the polygon)
[
]
],"type": "Polygon",
}, }
# Create a new map to display the generated polygon
= Map(
aoi_map
# Base map is set to OpenStreetMap
="OpenStreetMap",
tiles
# Define the spatial properties for the map
=[
location
# Set the center of the map
35, -120
],
# Set the zoom value
=7,
zoom_start
)
# Insert the Coastal California polygon to the map
="Coastal California").add_to(aoi_map)
folium.GeoJson(california_coast_aoi, name
# Visualize the map
aoi_map
Now that you created the polygon for the area of interest, you need to develop a function that runs through the data collection and generates the statistics for a specific item (granule) within the boundaries of the AOI polygon.
# The bounding box should be passed to the geojson param as a geojson Feature or FeatureCollection
# Create a function that retrieves information regarding a specific granule using its asset name and raster identifier and generates the statistics for it
# The function takes an item (granule) and a JSON (polygon) as input parameters
def generate_stats(item, geojson):
# A POST request is made to submit the data associated with the item of interest (specific observation) within the boundaries of the polygon to compute its statistics
= requests.post(
result
# Raster API Endpoint for computing statistics
f"{RASTER_API_URL}/cog/statistics",
# Pass the URL to the item, asset name, and raster identifier as parameters
={"url": item["assets"][asset_name]["href"]},
params
# Send the GeoJSON object (polygon) along with the request
=geojson,
json
# Return the response in JSON format
).json()
# Print the result
print(result)
# Return a dictionary containing the computed statistics along with the item's datetime information.
return {
**result["properties"],
"datetime": item["properties"]["start_datetime"],
}
Before you run the generated function in the previous step on a specific item (observation), you need to check the total number of items available within the collection and retrieve the information regarding their start date-time.
# Check the total number of items available within the collection
= requests.get(
items f"{STAC_API_URL}/collections/{collection_name}/items?limit=600"
"features"]
).json()[
# Print the total number of items (granules) found
print(f"Found {len(items)} items")
Found 36 items
# Examine the first item in the collection
0] items[
{'id': 'eccodarwin-co2flux-monthgrid-v5-202212',
'bbox': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'type': 'Feature',
'links': [{'rel': 'collection',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5'},
{'rel': 'parent',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5'},
{'rel': 'root',
'type': 'application/json',
'href': 'https://earth.gov/ghgcenter/api/stac/'},
{'rel': 'self',
'type': 'application/geo+json',
'href': 'https://earth.gov/ghgcenter/api/stac/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212'},
{'title': 'Map of Item',
'href': 'https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/map?assets=co2&nodata=nan&rescale=-0.0007%2C0.0002&colormap_name=bwr',
'rel': 'preview',
'type': 'text/html'}],
'assets': {'co2': {'href': 's3://ghgc-data-store/eccodarwin-co2flux-monthgrid-v5/ECCO-Darwin_CO2_flux_202212.tif',
'type': 'image/tiff; application=geotiff',
'roles': ['data', 'layer'],
'title': 'Air-Sea CO₂ Flux',
'proj:bbox': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'proj:epsg': 4326.0,
'proj:shape': [721.0, 1440.0],
'description': 'Monthly mean air-sea CO₂ flux (negative into ocean).',
'raster:bands': [{'scale': 1.0,
'offset': 0.0,
'sampling': 'area',
'data_type': 'float64',
'histogram': {'max': 1e+20,
'min': -0.0560546528687938,
'count': 11.0,
'buckets': [338606.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 186706.0]},
'statistics': {'mean': 3.554192556042885e+19,
'stddev': 4.786401658343999e+19,
'maximum': 1e+20,
'minimum': -0.0560546528687938,
'valid_percent': 0.0001903630604288499}}],
'proj:geometry': {'type': 'Polygon',
'coordinates': [[[-180.125, -90.124826629681],
[179.875, -90.124826629681],
[179.875, 89.875173370319],
[-180.125, 89.875173370319],
[-180.125, -90.124826629681]]]},
'proj:projjson': {'id': {'code': 4326.0, 'authority': 'EPSG'},
'name': 'WGS 84',
'type': 'GeographicCRS',
'datum': {'name': 'World Geodetic System 1984',
'type': 'GeodeticReferenceFrame',
'ellipsoid': {'name': 'WGS 84',
'semi_major_axis': 6378137.0,
'inverse_flattening': 298.257223563}},
'$schema': 'https://proj.org/schemas/v0.4/projjson.schema.json',
'coordinate_system': {'axis': [{'name': 'Geodetic latitude',
'unit': 'degree',
'direction': 'north',
'abbreviation': 'Lat'},
{'name': 'Geodetic longitude',
'unit': 'degree',
'direction': 'east',
'abbreviation': 'Lon'}],
'subtype': 'ellipsoidal'}},
'proj:transform': [0.25,
0.0,
-180.125,
0.0,
-0.24965325936199723,
89.875173370319,
0.0,
0.0,
1.0]},
'rendered_preview': {'title': 'Rendered preview',
'href': 'https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202212/preview.png?assets=co2&nodata=nan&rescale=-0.0007%2C0.0002&colormap_name=bwr',
'rel': 'preview',
'roles': ['overview'],
'type': 'image/png'}},
'geometry': {'type': 'Polygon',
'coordinates': [[[-180.125, -90.124826629681],
[179.875, -90.124826629681],
[179.875, 89.875173370319],
[-180.125, 89.875173370319],
[-180.125, -90.124826629681]]]},
'collection': 'eccodarwin-co2flux-monthgrid-v5',
'properties': {'end_datetime': '2022-12-31T00:00:00+00:00',
'start_datetime': '2022-12-01T00:00:00+00:00'},
'stac_version': '1.0.0',
'stac_extensions': ['https://stac-extensions.github.io/raster/v1.1.0/schema.json',
'https://stac-extensions.github.io/projection/v1.1.0/schema.json']}
# Generate a for loop that iterates over all the existing items in the collection
for item in items:
# The loop will then retrieve the information for the start datetime of each item in the list
print(item["properties"]["start_datetime"])
# Exit the loop after printing the start datetime for the first item in the collection
break
2022-12-01T00:00:00+00:00
Generate the statistics for the AOI
%%time
# %%time = Wall time (execution time) for running the code below
# Generate statistics using the created function "generate_stats" within the bounding box defined by the aoi polygon
= {}
stats for item in items:
= item["properties"]["start_datetime"] # Get the associated date
date = date[:7].replace('-', '') # Convert datetime to year-month
year_month = generate_stats(item, california_coast_aoi) stats[year_month]
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00010515466364758998, 'max': -2.6339156087043894e-05, 'mean': -6.713517054587462e-05, 'count': 86.62000274658203, 'sum': -0.005815248657075913, 'std': 1.9970110657389885e-05, 'median': -6.633380711657132e-05, 'majority': -0.00010515466364758998, 'minority': -0.00010515466364758998, 'unique': 115.0, 'histogram': [[9.0, 8.0, 9.0, 8.0, 22.0, 10.0, 18.0, 16.0, 8.0, 7.0], [-0.00010515466364758998, -9.727311289153537e-05, -8.939156213548077e-05, -8.151001137942615e-05, -7.362846062337154e-05, -6.574690986731694e-05, -5.786535911126232e-05, -4.9983808355207714e-05, -4.2102257599153106e-05, -3.422070684309849e-05, -2.6339156087043894e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00010359588859230771, 'percentile_98': -3.194067887033325e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -5.3277011152059295e-05, 'max': 1.0281345607496425e-05, 'mean': -2.9511148643310123e-05, 'count': 86.62000274658203, 'sum': -0.0025562557765383136, 'std': 1.4074948906750663e-05, 'median': -3.1811414500257194e-05, 'majority': -5.3277011152059295e-05, 'minority': -5.3277011152059295e-05, 'unique': 115.0, 'histogram': [[6.0, 21.0, 17.0, 16.0, 13.0, 15.0, 11.0, 9.0, 5.0, 2.0], [-5.3277011152059295e-05, -4.692117547610372e-05, -4.056533980014815e-05, -3.4209504124192576e-05, -2.7853668448237005e-05, -2.1497832772281433e-05, -1.5141997096325857e-05, -8.786161420370289e-06, -2.4303257444147137e-06, 3.9255099315408615e-06, 1.0281345607496425e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -5.0656071519948205e-05, 'percentile_98': -1.1089975827344017e-06}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -3.414260442530581e-05, 'max': 4.739613790624944e-05, 'mean': -1.7485122119025166e-06, 'count': 86.62000274658203, 'sum': -0.00015145613259742822, 'std': 1.8377925219163667e-05, 'median': -2.5058112932914285e-06, 'majority': -3.414260442530581e-05, 'minority': -3.414260442530581e-05, 'unique': 115.0, 'histogram': [[10.0, 15.0, 16.0, 13.0, 14.0, 15.0, 14.0, 12.0, 3.0, 3.0], [-3.414260442530581e-05, -2.5988730192150287e-05, -1.7834855958994763e-05, -9.680981725839238e-06, -1.5271074926837138e-06, 6.626766740471814e-06, 1.4780640973627335e-05, 2.2934515206782857e-05, 3.1088389439938384e-05, 3.924226367309391e-05, 4.739613790624944e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -3.2000126492079525e-05, 'percentile_98': 3.4402321746323974e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -4.692151229820521e-05, 'max': 4.9598764852074465e-05, 'mean': -6.888228971014557e-06, 'count': 86.62000274658203, 'sum': -0.0005966584123883669, 'std': 2.0927005497798602e-05, 'median': -4.227936798483556e-06, 'majority': -4.692151229820521e-05, 'minority': -4.692151229820521e-05, 'unique': 115.0, 'histogram': [[6.0, 13.0, 20.0, 14.0, 17.0, 12.0, 24.0, 5.0, 1.0, 3.0], [-4.692151229820521e-05, -3.726948458317724e-05, -2.7617456868149273e-05, -1.7965429153121305e-05, -8.313401438093338e-06, 1.338626276934629e-06, 1.0990653991962596e-05, 2.0642681706990564e-05, 3.029470942201853e-05, 3.99467371370465e-05, 4.9598764852074465e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -4.511987338653629e-05, 'percentile_98': 2.716666299628972e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -9.080547748822169e-05, 'max': -1.5537571619247306e-06, 'mean': -3.822837370543178e-05, 'count': 86.62000274658203, 'sum': -0.003311341835361865, 'std': 2.0816852021854977e-05, 'median': -3.259453885688862e-05, 'majority': -9.080547748822169e-05, 'minority': -9.080547748822169e-05, 'unique': 115.0, 'histogram': [[2.0, 10.0, 4.0, 8.0, 11.0, 15.0, 21.0, 20.0, 12.0, 12.0], [-9.080547748822169e-05, -8.1880305455592e-05, -7.29551334229623e-05, -6.40299613903326e-05, -5.5104789357702906e-05, -4.6179617325073214e-05, -3.7254445292443516e-05, -2.8329273259813817e-05, -1.9404101227184125e-05, -1.0478929194554433e-05, -1.5537571619247306e-06]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -8.052887732505406e-05, 'percentile_98': -7.471908842652856e-06}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00015569413035950813, 'max': -2.4125961199499128e-05, 'mean': -0.0001042554239276152, 'count': 86.62000274658203, 'sum': -0.009030605106956103, 'std': 2.2317479060651927e-05, 'median': -0.00010594736607856508, 'majority': -0.00015569413035950813, 'minority': -0.00015569413035950813, 'unique': 115.0, 'histogram': [[2.0, 9.0, 25.0, 26.0, 24.0, 10.0, 9.0, 4.0, 4.0, 2.0], [-0.00015569413035950813, -0.00014253731344350724, -0.00012938049652750632, -0.00011622367961150543, -0.00010306686269550453, -8.991004577950363e-05, -7.675322886350274e-05, -6.359641194750183e-05, -5.043959503150093e-05, -3.7282778115500025e-05, -2.4125961199499128e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00014154422787180773, 'percentile_98': -4.717074647335924e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00023412670449494892, 'max': -4.360531565345715e-05, 'mean': -0.00017566129908107503, 'count': 86.62000274658203, 'sum': -0.015215782208870886, 'std': 3.3002737566243304e-05, 'median': -0.00017951213292013204, 'majority': -0.00023412670449494892, 'minority': -0.00023412670449494892, 'unique': 115.0, 'histogram': [[10.0, 25.0, 20.0, 29.0, 14.0, 8.0, 4.0, 2.0, 2.0, 1.0], [-0.00023412670449494892, -0.00021507456561079975, -0.00019602242672665056, -0.0001769702878425014, -0.00015791814895835222, -0.00013886601007420305, -0.00011981387119005387, -0.00010076173230590468, -8.170959342175551e-05, -6.265745453760635e-05, -4.360531565345715e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.000226922687486708, 'percentile_98': -9.464532724533128e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00024332760936736196, 'max': -6.65548876609859e-05, 'mean': -0.00017796363014360882, 'count': 86.62000274658203, 'sum': -0.015415210131831104, 'std': 3.3829679476222626e-05, 'median': -0.00017883927844132084, 'majority': -0.00024332760936736196, 'minority': -0.00024332760936736196, 'unique': 115.0, 'histogram': [[10.0, 12.0, 18.0, 21.0, 23.0, 16.0, 4.0, 7.0, 2.0, 2.0], [-0.00024332760936736196, -0.00022565033719672436, -0.00020797306502608675, -0.00019029579285544915, -0.00017261852068481154, -0.00015494124851417394, -0.0001372639763435363, -0.0001195867041728987, -0.0001019094320022611, -8.42321598316235e-05, -6.65548876609859e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.000234296558831545, 'percentile_98': -0.00010601648081698702}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00023333175939176657, 'max': -6.775292327902623e-05, 'mean': -0.00017043679434868597, 'count': 86.62000274658203, 'sum': -0.014763235594601815, 'std': 3.0756088797644315e-05, 'median': -0.00016774749191505306, 'majority': -0.00023333175939176657, 'minority': -0.00023333175939176657, 'unique': 115.0, 'histogram': [[8.0, 12.0, 14.0, 23.0, 28.0, 13.0, 8.0, 3.0, 4.0, 2.0], [-0.00023333175939176657, -0.00021677387578049253, -0.0002002159921692185, -0.00018365810855794446, -0.00016710022494667044, -0.0001505423413353964, -0.00013398445772412235, -0.00011742657411284832, -0.00010086869050157429, -8.431080689030025e-05, -6.775292327902623e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00023038987188993542, 'percentile_98': -9.912092486965628e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00019244893568340932, 'max': -4.626869487573467e-05, 'mean': -0.0001248641236325952, 'count': 86.62000274658203, 'sum': -0.010815730732004956, 'std': 2.379805898277995e-05, 'median': -0.00012160861837914462, 'majority': -0.00019244893568340932, 'minority': -0.00019244893568340932, 'unique': 115.0, 'histogram': [[6.0, 7.0, 5.0, 6.0, 32.0, 35.0, 14.0, 6.0, 2.0, 2.0], [-0.00019244893568340932, -0.00017783091160264187, -0.0001632128875218744, -0.0001485948634411069, -0.00013397683936033946, -0.000119358815279572, -0.00010474079119880453, -9.012276711803706e-05, -7.55047430372696e-05, -6.088671895650212e-05, -4.626869487573467e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00018311936297626542, 'percentile_98': -7.822118982509477e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00010173065143143008, 'max': -2.584304744996503e-05, 'mean': -7.344011234961877e-05, 'count': 86.62000274658203, 'sum': -0.006361382733433271, 'std': 1.4935713273717173e-05, 'median': -7.270195273017876e-05, 'majority': -0.00010173065143143008, 'minority': -0.00010173065143143008, 'unique': 115.0, 'histogram': [[7.0, 16.0, 13.0, 27.0, 23.0, 13.0, 4.0, 8.0, 1.0, 3.0], [-0.00010173065143143008, -9.414189103328358e-05, -8.655313063513708e-05, -7.896437023699056e-05, -7.137560983884407e-05, -6.378684944069755e-05, -5.619808904255105e-05, -4.8609328644404545e-05, -4.102056824625804e-05, -3.343180784811154e-05, -2.584304744996503e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -9.958162758843473e-05, 'percentile_98': -4.3911333780088374e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0002954860733280958, 'max': -5.5176877843732515e-05, 'mean': -0.00020816867585089378, 'count': 86.62000274658203, 'sum': -0.018031571273956763, 'std': 4.543075252453149e-05, 'median': -0.0002131177659205654, 'majority': -0.0002954860733280958, 'minority': -0.0002954860733280958, 'unique': 115.0, 'histogram': [[11.0, 13.0, 18.0, 34.0, 15.0, 7.0, 7.0, 4.0, 4.0, 2.0], [-0.0002954860733280958, -0.00027145515377965945, -0.0002474242342312231, -0.0002233933146827868, -0.00019936239513435047, -0.00017533147558591413, -0.00015130055603747783, -0.0001272696364890415, -0.00010323871694060515, -7.920779739216882e-05, -5.5176877843732515e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.0002897962610530328, 'percentile_98': -0.000100708043492395}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0001281229180544866, 'max': -4.706282658110175e-05, 'mean': -9.715623845920787e-05, 'count': 86.62000274658203, 'sum': -0.008415673642184164, 'std': 1.227680676700787e-05, 'median': -9.735475867856487e-05, 'majority': -0.0001281229180544866, 'minority': -0.0001281229180544866, 'unique': 115.0, 'histogram': [[5.0, 7.0, 10.0, 36.0, 25.0, 14.0, 11.0, 5.0, 1.0, 1.0], [-0.0001281229180544866, -0.00012001690890714811, -0.00011191089975980962, -0.00010380489061247114, -9.569888146513265e-05, -8.759287231779417e-05, -7.948686317045569e-05, -7.138085402311721e-05, -6.327484487577872e-05, -5.516883572844024e-05, -4.706282658110175e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.000123848819823941, 'percentile_98': -7.226910207959458e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -8.282967080610922e-05, 'max': -2.0952414726973794e-05, 'mean': -6.107579706848998e-05, 'count': 86.62000274658203, 'sum': -0.005290385709822289, 'std': 1.3509642082027697e-05, 'median': -6.375022750447845e-05, 'majority': -8.282967080610922e-05, 'minority': -8.282967080610922e-05, 'unique': 115.0, 'histogram': [[9.0, 18.0, 22.0, 22.0, 10.0, 12.0, 11.0, 4.0, 4.0, 3.0], [-8.282967080610922e-05, -7.664194519819567e-05, -7.045421959028213e-05, -6.42664939823686e-05, -5.807876837445505e-05, -5.1891042766541503e-05, -4.5703317158627966e-05, -3.951559155071442e-05, -3.332786594280088e-05, -2.7140140334887334e-05, -2.0952414726973794e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -8.104369960526185e-05, 'percentile_98': -2.9440160502217717e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -8.228188138380643e-05, 'max': -2.219938231567791e-05, 'mean': -5.551456715650032e-05, 'count': 86.62000274658203, 'sum': -0.004808671959571371, 'std': 1.7142791563308453e-05, 'median': -5.9868326809943314e-05, 'majority': -8.228188138380643e-05, 'minority': -8.228188138380643e-05, 'unique': 115.0, 'histogram': [[9.0, 12.0, 19.0, 16.0, 9.0, 9.0, 13.0, 5.0, 15.0, 8.0], [-8.228188138380643e-05, -7.627363147699357e-05, -7.026538157018072e-05, -6.425713166336788e-05, -5.824888175655502e-05, -5.2240631849742166e-05, -4.623238194292932e-05, -4.022413203611647e-05, -3.4215882129303614e-05, -2.820763222249076e-05, -2.219938231567791e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -8.110128563149226e-05, 'percentile_98': -2.6928747397675633e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -4.7073752683007746e-05, 'max': 1.0643952881431232e-05, 'mean': -1.1711885681223084e-05, 'count': 86.62000274658203, 'sum': -0.0010144835698751983, 'std': 1.3965513149592162e-05, 'median': -1.2337799634271484e-05, 'majority': -4.7073752683007746e-05, 'minority': -4.7073752683007746e-05, 'unique': 115.0, 'histogram': [[4.0, 3.0, 3.0, 9.0, 18.0, 15.0, 15.0, 16.0, 12.0, 20.0], [-4.7073752683007746e-05, -4.130198212656385e-05, -3.553021157011995e-05, -2.9758441013676053e-05, -2.3986670457232156e-05, -1.8214899900788258e-05, -1.244312934434436e-05, -6.671358787900463e-06, -8.995882314565652e-07, 4.8721823249873325e-06, 1.0643952881431232e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -4.343687653862412e-05, 'percentile_98': 1.0633945096260036e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -4.4347183857908615e-05, 'max': 2.211462828039654e-05, 'mean': -3.139432806320912e-06, 'count': 86.62000274658203, 'sum': -0.00027193767830622714, 'std': 1.34768955636096e-05, 'median': -1.939379844781874e-06, 'majority': -4.4347183857908615e-05, 'minority': -4.4347183857908615e-05, 'unique': 115.0, 'histogram': [[3.0, 2.0, 2.0, 14.0, 14.0, 18.0, 12.0, 24.0, 21.0, 5.0], [-4.4347183857908615e-05, -3.77010026440781e-05, -3.1054821430247584e-05, -2.4408640216417072e-05, -1.7762459002586557e-05, -1.1116277788756041e-05, -4.4700965749255294e-06, 2.1760846389049892e-06, 8.822265852735501e-06, 1.5468447066566013e-05, 2.211462828039654e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -3.4440981707303044e-05, 'percentile_98': 1.690956352821826e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00010925971508853925, 'max': 3.7677876342250117e-06, 'mean': -2.144993925282313e-05, 'count': 86.62000274658203, 'sum': -0.0018579937969935571, 'std': 1.6606374648244326e-05, 'median': -1.772316630905369e-05, 'majority': -0.00010925971508853925, 'minority': -0.00010925971508853925, 'unique': 115.0, 'histogram': [[1.0, 1.0, 2.0, 0.0, 4.0, 5.0, 17.0, 21.0, 40.0, 24.0], [-0.00010925971508853925, -9.795696481626282e-05, -8.665421454398639e-05, -7.535146427170998e-05, -6.404871399943355e-05, -5.2745963727157116e-05, -4.14432134548807e-05, -3.014046318260427e-05, -1.883771291032784e-05, -7.534962638051411e-06, 3.7677876342250117e-06]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -6.255253714484405e-05, 'percentile_98': -9.154789882268865e-07}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00012082036816258734, 'max': -2.3478994770513282e-05, 'mean': -6.241454785524433e-05, 'count': 86.62000274658203, 'sum': -0.00540634830664794, 'std': 1.7333188060938812e-05, 'median': -6.38982674568887e-05, 'majority': -0.00012082036816258734, 'minority': -0.00012082036816258734, 'unique': 115.0, 'histogram': [[4.0, 2.0, 3.0, 5.0, 14.0, 34.0, 27.0, 13.0, 7.0, 6.0], [-0.00012082036816258734, -0.00011108623082337994, -0.00010135209348417253, -9.161795614496512e-05, -8.188381880575772e-05, -7.214968146655032e-05, -6.241554412734292e-05, -5.2681406788135504e-05, -4.29472694489281e-05, -3.32131321097207e-05, -2.3478994770513282e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00011528931527092115, 'percentile_98': -3.055876826658794e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00023948827066906818, 'max': -5.144603688901141e-05, 'mean': -0.0001667495405715303, 'count': 86.62000274658203, 'sum': -0.014443845662297247, 'std': 3.542955442362702e-05, 'median': -0.00017275226630492568, 'majority': -0.00023948827066906818, 'minority': -0.00023948827066906818, 'unique': 115.0, 'histogram': [[2.0, 11.0, 31.0, 23.0, 17.0, 13.0, 8.0, 6.0, 1.0, 3.0], [-0.00023948827066906818, -0.0002206840472910625, -0.00020187982391305684, -0.00018307560053505115, -0.00016427137715704546, -0.0001454671537790398, -0.00012666293040103412, -0.00010785870702302846, -8.905448364502277e-05, -7.025026026701709e-05, -5.144603688901141e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.0002168971831556677, 'percentile_98': -6.526345074666982e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0002351198672666438, 'max': -5.7465317448293746e-05, 'mean': -0.00017317464170801014, 'count': 86.62000274658203, 'sum': -0.015000387940386196, 'std': 2.8935127203420645e-05, 'median': -0.00017844650602075196, 'majority': -0.0002351198672666438, 'minority': -0.0002351198672666438, 'unique': 115.0, 'histogram': [[3.0, 17.0, 31.0, 24.0, 19.0, 7.0, 5.0, 6.0, 2.0, 1.0], [-0.0002351198672666438, -0.0002173544122848088, -0.0001995889573029738, -0.0001818235023211388, -0.00016405804733930378, -0.00014629259235746878, -0.0001285271373756338, -0.00011076168239379877, -9.299622741196377e-05, -7.523077243012878e-05, -5.7465317448293746e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00022162898371092134, 'percentile_98': -9.759098805227394e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.000198452983437136, 'max': -5.764483999872821e-05, 'mean': -0.00014113825817569205, 'count': 86.62000274658203, 'sum': -0.01222539631082625, 'std': 2.594767069916286e-05, 'median': -0.0001363527003899194, 'majority': -0.000198452983437136, 'minority': -0.000198452983437136, 'unique': 115.0, 'histogram': [[7.0, 15.0, 13.0, 15.0, 28.0, 20.0, 6.0, 8.0, 1.0, 2.0], [-0.000198452983437136, -0.00018437216909329522, -0.00017029135474945446, -0.00015621054040561367, -0.00014212972606177289, -0.00012804891171793213, -0.00011396809737409134, -9.988728303025055e-05, -8.580646868640978e-05, -7.1725654342569e-05, -5.764483999872821e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00018605479098279375, 'percentile_98': -8.720032420082412e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00024043604702766373, 'max': -6.154515941883043e-05, 'mean': -0.00017970813716543328, 'count': 86.62000274658203, 'sum': -0.01556631933485297, 'std': 3.217445686518619e-05, 'median': -0.0001776297677285159, 'majority': -0.00024043604702766373, 'minority': -0.00024043604702766373, 'unique': 115.0, 'histogram': [[14.0, 9.0, 19.0, 30.0, 23.0, 7.0, 4.0, 7.0, 1.0, 1.0], [-0.00024043604702766373, -0.0002225469582667804, -0.00020465786950589707, -0.00018676878074501375, -0.0001688796919841304, -0.00015099060322324709, -0.00013310151446236377, -0.00011521242570148042, -9.73233369405971e-05, -7.943424817971378e-05, -6.154515941883043e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00023946828863740917, 'percentile_98': -0.00010489454506950395}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0001606134280190246, 'max': -5.403518111078113e-05, 'mean': -0.00012517344705245486, 'count': 86.62000274658203, 'sum': -0.01084252432748278, 'std': 1.9982041543139306e-05, 'median': -0.0001247355985875484, 'majority': -0.0001606134280190246, 'minority': -0.0001606134280190246, 'unique': 115.0, 'histogram': [[11.0, 9.0, 28.0, 35.0, 13.0, 4.0, 8.0, 3.0, 1.0, 3.0], [-0.0001606134280190246, -0.00014995560332820024, -0.0001392977786373759, -0.00012863995394655155, -0.0001179821292557272, -0.00010732430456490286, -9.666647987407852e-05, -8.600865518325416e-05, -7.535083049242982e-05, -6.469300580160548e-05, -5.403518111078113e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00015970112532852465, 'percentile_98': -8.13887761059406e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0001396797615686017, 'max': -3.8912624507455626e-05, 'mean': -0.00010799848383097121, 'count': 86.62000274658203, 'sum': -0.009354828966065421, 'std': 1.921787145397108e-05, 'median': -0.00011061603443556379, 'majority': -0.0001396797615686017, 'minority': -0.0001396797615686017, 'unique': 115.0, 'histogram': [[8.0, 20.0, 29.0, 29.0, 10.0, 4.0, 5.0, 5.0, 2.0, 3.0], [-0.0001396797615686017, -0.00012960304786248708, -0.00011952633415637247, -0.00010944962045025788, -9.937290674414327e-05, -8.929619303802866e-05, -7.921947933191406e-05, -6.914276562579945e-05, -5.906605191968484e-05, -4.898933821357023e-05, -3.8912624507455626e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00013944495173048448, 'percentile_98': -6.173149714185682e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00012740280989261335, 'max': -2.8346161791623657e-05, 'mean': -8.026635359529086e-05, 'count': 86.62000274658203, 'sum': -0.006952671768882219, 'std': 1.548494314279806e-05, 'median': -8.017032674466592e-05, 'majority': -0.00012740280989261335, 'minority': -0.00012740280989261335, 'unique': 115.0, 'histogram': [[4.0, 3.0, 5.0, 16.0, 30.0, 32.0, 9.0, 9.0, 5.0, 2.0], [-0.00012740280989261335, -0.00011749714508251438, -0.0001075914802724154, -9.768581546231644e-05, -8.778015065221747e-05, -7.78744858421185e-05, -6.796882103201954e-05, -5.806315622192056e-05, -4.815749141182159e-05, -3.8251826601722614e-05, -2.8346161791623657e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00012013012799980257, 'percentile_98': -4.7438238898632615e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -7.559188637249618e-05, 'max': 1.5475180513715358e-05, 'mean': -1.3546911579380317e-05, 'count': 86.62000274658203, 'sum': -0.001173433518213627, 'std': 1.620359275629394e-05, 'median': -1.1386375687512626e-05, 'majority': -7.559188637249618e-05, 'minority': -7.559188637249618e-05, 'unique': 115.0, 'histogram': [[3.0, 2.0, 2.0, 4.0, 3.0, 6.0, 28.0, 32.0, 23.0, 12.0], [-7.559188637249618e-05, -6.648517968387502e-05, -5.737847299525388e-05, -4.827176630663272e-05, -3.9165059618011566e-05, -3.0058352929390413e-05, -2.0951646240769254e-05, -1.1844939552148109e-05, -2.73823286352695e-06, 6.368473825094209e-06, 1.5475180513715358e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -6.56740828809353e-05, 'percentile_98': 9.818050408691993e-06}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -3.5119286720466285e-05, 'max': 3.6720805854810556e-05, 'mean': -4.01986882736388e-06, 'count': 86.62000274658203, 'sum': -0.0003482010488671588, 'std': 1.2930089975850738e-05, 'median': -5.748787221072529e-06, 'majority': -3.5119286720466285e-05, 'minority': -3.5119286720466285e-05, 'unique': 115.0, 'histogram': [[4.0, 6.0, 10.0, 30.0, 21.0, 14.0, 14.0, 6.0, 8.0, 2.0], [-3.5119286720466285e-05, -2.79352774629386e-05, -2.075126820541092e-05, -1.3567258947883238e-05, -6.383249690355553e-06, 8.007595671721319e-07, 7.98476882469981e-06, 1.5168778082227495e-05, 2.235278733975518e-05, 2.9536796597282857e-05, 3.6720805854810556e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -3.1207465337933084e-05, 'percentile_98': 2.4090088250820796e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -7.682738067855773e-05, 'max': 3.1010669269776924e-05, 'mean': -2.4545104974686847e-05, 'count': 86.62000274658203, 'sum': -0.002126097060322519, 'std': 2.1145460098847803e-05, 'median': -2.2887761043306587e-05, 'majority': -7.682738067855773e-05, 'minority': -7.682738067855773e-05, 'unique': 115.0, 'histogram': [[6.0, 6.0, 5.0, 11.0, 24.0, 24.0, 16.0, 11.0, 8.0, 4.0], [-7.682738067855773e-05, -6.604357568372426e-05, -5.52597706888908e-05, -4.447596569405734e-05, -3.369216069922387e-05, -2.29083557043904e-05, -1.2124550709556944e-05, -1.3407457147234756e-06, 9.443059280109993e-06, 2.0226864274943462e-05, 3.1010669269776924e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -7.221507945148222e-05, 'percentile_98': 1.4580285108430741e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.0001739888434708829, 'max': 1.6746078754854247e-05, 'mean': -5.059342357342047e-05, 'count': 86.62000274658203, 'sum': -0.004382402488888669, 'std': 4.0345096987067046e-05, 'median': -3.928963272902391e-05, 'majority': -0.0001739888434708829, 'minority': -0.0001739888434708829, 'unique': 115.0, 'histogram': [[4.0, 7.0, 3.0, 4.0, 3.0, 5.0, 24.0, 35.0, 20.0, 10.0], [-0.0001739888434708829, -0.00015491535124830918, -0.00013584185902573546, -0.00011676836680316177, -9.769487458058805e-05, -7.862138235801433e-05, -5.954789013544062e-05, -4.0474397912866915e-05, -2.1400905690293194e-05, -2.327413467719474e-06, 1.6746078754854247e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00016102732716132643, 'percentile_98': 9.356727631679761e-07}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00014633795621411537, 'max': 2.3441603978065428e-05, 'mean': -4.048992711367719e-05, 'count': 86.62000274658203, 'sum': -0.0035072375977956245, 'std': 3.2765846677913356e-05, 'median': -3.3813016984752075e-05, 'majority': -0.00014633795621411537, 'minority': -0.00014633795621411537, 'unique': 115.0, 'histogram': [[2.0, 3.0, 3.0, 8.0, 7.0, 20.0, 19.0, 31.0, 13.0, 9.0], [-0.00014633795621411537, -0.0001293600001948973, -0.00011238204417567921, -9.540408815646113e-05, -7.842613213724305e-05, -6.144817611802497e-05, -4.4470220098806896e-05, -2.7492264079588818e-05, -1.0514308060370739e-05, 6.4636479588473395e-06, 2.3441603978065428e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00012357318220284085, 'percentile_98': 8.184955528085216e-06}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00012790116405794549, 'max': -7.347870322049863e-06, 'mean': -5.153682952589357e-05, 'count': 86.62000274658203, 'sum': -0.004464120315083031, 'std': 2.5396023776703976e-05, 'median': -4.8605161545713946e-05, 'majority': -0.00012790116405794549, 'minority': -0.00012790116405794549, 'unique': 115.0, 'histogram': [[3.0, 2.0, 4.0, 7.0, 11.0, 16.0, 18.0, 17.0, 24.0, 13.0], [-0.00012790116405794549, -0.00011584583468435592, -0.00010379050531076635, -9.17351759371768e-05, -7.967984656358724e-05, -6.762451718999767e-05, -5.556918781640812e-05, -4.3513858442818554e-05, -3.145852906922899e-05, -1.9403199695639423e-05, -7.347870322049863e-06]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.0001218894177271193, 'percentile_98': -1.5472465731372054e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00013921063076278585, 'max': -3.5765228838438095e-05, 'mean': -8.583485395473218e-05, 'count': 86.62000274658203, 'sum': -0.007435015285311369, 'std': 2.0287396476037552e-05, 'median': -8.360445823023726e-05, 'majority': -0.00013921063076278585, 'minority': -0.00013921063076278585, 'unique': 115.0, 'histogram': [[3.0, 8.0, 9.0, 8.0, 16.0, 22.0, 25.0, 16.0, 5.0, 3.0], [-0.00013921063076278585, -0.00012886609057035107, -0.0001185215503779163, -0.00010817701018548153, -9.783246999304675e-05, -8.748792980061198e-05, -7.714338960817721e-05, -6.679884941574243e-05, -5.645430922330766e-05, -4.610976903087288e-05, -3.5765228838438095e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.0001321436861733554, 'percentile_98': -4.9478961179763185e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00011453414031127196, 'max': -2.5153009306526816e-05, 'mean': -5.606484279560035e-05, 'count': 86.62000274658203, 'sum': -0.004856336836941592, 'std': 1.3576859561140137e-05, 'median': -5.2092425995657114e-05, 'majority': -0.00011453414031127196, 'minority': -0.00011453414031127196, 'unique': 115.0, 'histogram': [[2.0, 2.0, 3.0, 1.0, 5.0, 18.0, 27.0, 39.0, 14.0, 4.0], [-0.00011453414031127196, -0.00010559602721079744, -9.665791411032294e-05, -8.771980100984842e-05, -7.87816879093739e-05, -6.984357480889939e-05, -6.090546170842488e-05, -5.196734860795037e-05, -4.302923550747585e-05, -3.409112240700133e-05, -2.5153009306526816e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -9.761120728455703e-05, 'percentile_98': -3.4258626892058585e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00021918676108497462, 'max': -3.927832631416977e-05, 'mean': -0.00012144348425158578, 'count': 86.62000274658203, 'sum': -0.010519434939426852, 'std': 2.9769797386936854e-05, 'median': -0.00011626481094279005, 'majority': -0.00021918676108497462, 'minority': -0.00021918676108497462, 'unique': 115.0, 'histogram': [[5.0, 2.0, 5.0, 6.0, 12.0, 35.0, 28.0, 12.0, 8.0, 2.0], [-0.00021918676108497462, -0.00020119591760789414, -0.00018320507413081366, -0.00016521423065373315, -0.00014722338717665267, -0.0001292325436995722, -0.0001112417002224917, -9.32508567454112e-05, -7.526001326833072e-05, -5.726916979125024e-05, -3.927832631416977e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.0002064151684468108, 'percentile_98': -6.805256999965305e-05}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-124.19, 37.86], [-123.11, 37.86], [-119.96, 33.16], [-121.13, 33.16], [-124.19, 37.86]]]}, 'properties': {'statistics': {'b1': {'min': -0.00015412138841721786, 'max': -3.145271371838777e-05, 'mean': -9.593350082157177e-05, 'count': 86.62000274658203, 'sum': -0.008309760104653776, 'std': 2.9374048721393294e-05, 'median': -8.783572604921066e-05, 'majority': -0.00015412138841721786, 'minority': -0.00015412138841721786, 'unique': 115.0, 'histogram': [[10.0, 10.0, 11.0, 3.0, 15.0, 28.0, 20.0, 9.0, 5.0, 4.0], [-0.00015412138841721786, -0.00014185452094733484, -0.00012958765347745183, -0.00011732078600756883, -0.00010505391853768583, -9.278705106780281e-05, -8.05201835979198e-05, -6.825331612803679e-05, -5.5986448658153776e-05, -4.371958118827076e-05, -3.145271371838777e-05]], 'valid_percent': 31.94, 'masked_pixels': 245.0, 'valid_pixels': 115.0, 'percentile_2': -0.00015409053848538357, 'percentile_98': -4.834538500993245e-05}}}}
CPU times: user 143 ms, sys: 35.5 ms, total: 178 ms
Wall time: 11.5 s
# Print the stats for the observation of interest
# For example, for printing the stats for the December 2022 tile, you can change the date inside the bracket "['YYYYMM']" to "['202212']
'202212'] stats[
{'statistics': {'b1': {'min': -0.00010515466364758998,
'max': -2.6339156087043894e-05,
'mean': -6.713517054587462e-05,
'count': 86.62000274658203,
'sum': -0.005815248657075913,
'std': 1.9970110657389885e-05,
'median': -6.633380711657132e-05,
'majority': -0.00010515466364758998,
'minority': -0.00010515466364758998,
'unique': 115.0,
'histogram': [[9.0, 8.0, 9.0, 8.0, 22.0, 10.0, 18.0, 16.0, 8.0, 7.0],
[-0.00010515466364758998,
-9.727311289153537e-05,
-8.939156213548077e-05,
-8.151001137942615e-05,
-7.362846062337154e-05,
-6.574690986731694e-05,
-5.786535911126232e-05,
-4.9983808355207714e-05,
-4.2102257599153106e-05,
-3.422070684309849e-05,
-2.6339156087043894e-05]],
'valid_percent': 31.94,
'masked_pixels': 245.0,
'valid_pixels': 115.0,
'percentile_2': -0.00010359588859230771,
'percentile_98': -3.194067887033325e-05}},
'datetime': '2022-12-01T00:00:00+00:00'}
Create a function that goes through every single item in the collection and populates their properties - including the minimum, maximum, and sum of their values - in a table.
# Create a function that converts statistics in JSON format into a pandas DataFrame
def clean_stats(stats_json) -> pd.DataFrame:
'display.float_format', '{:.20f}'.format)
pd.set_option(= [stats_json[datetime] for datetime in stats_json]
stats_json_ # Normalize the JSON data
= pd.json_normalize(stats_json_)
df
# Replace the naming "statistics.b1" in the columns
= [col.replace("statistics.b1.", "") for col in df.columns]
df.columns
# Set the datetime format
"date"] = pd.to_datetime(df["datetime"])
df[
# Return the cleaned format
return df
# Apply the generated function on the stats data
= clean_stats(stats)
df
# Display the stats for the first 5 granules in the collection in the table
# Change the value in the parenthesis to show more or a smaller number of rows in the table
5) df.head(
datetime | min | max | mean | count | sum | std | median | majority | minority | unique | histogram | valid_percent | masked_pixels | valid_pixels | percentile_2 | percentile_98 | date | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2022-12-01T00:00:00+00:00 | -0.000105 | -0.000026 | -0.000067 | 86.620003 | -0.005815 | 0.000020 | -0.000066 | -0.000105 | -0.000105 | 115.0 | [[9.0, 8.0, 9.0, 8.0, 22.0, 10.0, 18.0, 16.0, ... | 31.94 | 245.0 | 115.0 | -0.000104 | -0.000032 | 2022-12-01 00:00:00+00:00 |
1 | 2022-11-01T00:00:00+00:00 | -0.000053 | 0.000010 | -0.000030 | 86.620003 | -0.002556 | 0.000014 | -0.000032 | -0.000053 | -0.000053 | 115.0 | [[6.0, 21.0, 17.0, 16.0, 13.0, 15.0, 11.0, 9.0... | 31.94 | 245.0 | 115.0 | -0.000051 | -0.000001 | 2022-11-01 00:00:00+00:00 |
2 | 2022-10-01T00:00:00+00:00 | -0.000034 | 0.000047 | -0.000002 | 86.620003 | -0.000151 | 0.000018 | -0.000003 | -0.000034 | -0.000034 | 115.0 | [[10.0, 15.0, 16.0, 13.0, 14.0, 15.0, 14.0, 12... | 31.94 | 245.0 | 115.0 | -0.000032 | 0.000034 | 2022-10-01 00:00:00+00:00 |
3 | 2022-09-01T00:00:00+00:00 | -0.000047 | 0.000050 | -0.000007 | 86.620003 | -0.000597 | 0.000021 | -0.000004 | -0.000047 | -0.000047 | 115.0 | [[6.0, 13.0, 20.0, 14.0, 17.0, 12.0, 24.0, 5.0... | 31.94 | 245.0 | 115.0 | -0.000045 | 0.000027 | 2022-09-01 00:00:00+00:00 |
4 | 2022-08-01T00:00:00+00:00 | -0.000091 | -0.000002 | -0.000038 | 86.620003 | -0.003311 | 0.000021 | -0.000033 | -0.000091 | -0.000091 | 115.0 | [[2.0, 10.0, 4.0, 8.0, 11.0, 15.0, 21.0, 20.0,... | 31.94 | 245.0 | 115.0 | -0.000081 | -0.000007 | 2022-08-01 00:00:00+00:00 |
Time-Series Analysis
You can now explore the fossil fuel emission using this data collection (January 2020 -December 2022) for the Coastal California region. You can plot the data set using the code below:
# Sort the DataFrame by the datetime column so the plot displays the values from left to right (2020 -> 2022)
= df.sort_values(by="datetime")
df_sorted
# Plot the timeseries analysis of the monthly air-sea CO₂ flux changes along the coast of California
# Figure size: 20 representing the width, 10 representing the height
= plt.figure(figsize=(20, 10))
fig
plt.plot("datetime"], # X-axis: sorted datetime
df_sorted["max"], # Y-axis: maximum CO₂ value
df_sorted[="purple", # Line color
color="-", # Line style
linestyle=1, # Line width
linewidth="CO2 Emissions", # Legend label
label
)
# Display legend
plt.legend()
# Insert label for the X-axis
"Years")
plt.xlabel(
# Insert label for the Y-axis
"CO2 Emissions mmol m²/s")
plt.ylabel(
# Insert title for the plot
"CO2 Emission Values for Coastal California (2020-2022)")
plt.title(
# Rotate x-axis labels to avoid cramping
=90)
plt.xticks(rotation
# Add data citation
plt.text("datetime"].iloc[0], # X-coordinate of the text (first datetime value)
df_sorted["max"].min(), # Y-coordinate of the text (minimum CO2 value)
df_sorted[
# Text to be displayed
"Source: NASA Air-Sea CO₂ Flux, ECCO-Darwin Model v5",
=12, # Font size
fontsize="left", # Horizontal alignment
horizontalalignment="bottom", # Vertical alignment
verticalalignment="blue", # Text color
color
)
# Plot the time series
plt.show()
Next, you can take a closer look at the monthly CO₂ flux variability across this region for a particular day. For example, you can retrieve and display data collected during the September 2022 observation
# The 2022-09-01 observation is the 4th item in the list.
# Considering that a list starts with "0", we need to insert "3" in the "items[3]" statement
print(items[3]["properties"]["start_datetime"])
2022-09-01T00:00:00+00:00
# A GET request is made for the September 2022 tile
= requests.get(
September2022_co2_flux
# Pass the collection name, the item number in the list, and its ID
f"{RASTER_API_URL}/collections/{items[3]['collection']}/items/{items[3]['id']}/tilejson.json?"
# Don't change anything here
= f'eccodarwin-co2flux-monthgrid-v5-{date_of_interest}'
observation_of_interest
# Make a GET request to retrieve information for the september 2022 tile
# A GET request is made for the April 2021 tile.
= requests.get(
september_2022_tile # Pass the collection name and item ID directly from the first item in the list
f"{RASTER_API_URL}collections/{collection_name}/items/{observation_of_interest}/WebMercatorQuad/tilejson.json?"
(
# Pass the asset name
f"&assets={asset_name}"
# Pass the color formula and colormap for custom visualization
f"&color_formula=gamma+r+1.05&colormap_name={color_map}"
# Pass the minimum and maximum values for rescaling
f"&rescale={rescale_values['min']},{rescale_values['max']}"),
# Return the response in JSON format
).json()
# Print the properties of the retrieved granule to the console
september_2022_tile
{'tilejson': '2.2.0',
'version': '1.0.0',
'scheme': 'xyz',
'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/eccodarwin-co2flux-monthgrid-v5/items/eccodarwin-co2flux-monthgrid-v5-202209/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=co2&color_formula=gamma+r+1.05&colormap_name=magma&rescale=-0.0007%2C0.0007'],
'minzoom': 0,
'maxzoom': 24,
'bounds': [-180.125, -90.124826629681, 179.875, 89.875173370319],
'center': [-0.125, -0.1248266296809959, 0]}
# Create a new map to display the September 2022 tile
= Map(
aoi_map_bbox
# Base map is set to OpenStreetMap
="OpenStreetMap",
tiles
# Set the center of the map
=[
location34, -120
],
# Set the zoom value
=5.5,
zoom_start
)
# Define the map layer with the CO2 flux data for September 2022
= TileLayer(
map_layer =september_2022_tile["tiles"][0], # Path to retrieve the tile
tiles="GHG", # Set the attribution
attr= 0.7, # Adjust the transparency of the layer
opacity
)
# Add the layer to the map
map_layer.add_to(aoi_map_bbox)
# Add a legend to the map
# Minimum value = -0.0007, maximum value = 0.0007
= branca.colormap.LinearColormap(colors=["#0000FF", "#3399FF", "#66CCFF", "#FFFFFF", "#FF66CC", "#FF3399", "#FF0000"], vmin=-0.0007, vmax=0.0007)
colormap
# Add the data unit as caption
= 'Millimoles per meter squared per second (mmol m²/s)'
colormap.caption
# Define custom tick values for the legend bar
= [-0.0007, -0.00035, 0, 0.00035, 0.0007]
tick_val
# Create a HTML representation
= colormap._repr_html_()
legend_html
# Create a customized HTML structure for the legend
= f'''
legend_html <div style="position: fixed; bottom: 50px; left: 50px; z-index: 1000; width: 400px; height: auto; background-color: rgba(255, 255, 255, 0.8);
border-radius: 5px; border: 1px solid grey; padding: 10px; font-size: 14px; color: black;">
<b>{colormap.caption}</b><br>
<div style="display: flex; justify-content: space-between;">
<div>{tick_val[0]}</div>
<div>{tick_val[1]}</div>
<div>{tick_val[2]}</div>
<div>{tick_val[3]}</div>
<div>{tick_val[4]}</div>
</div>
<div style="background: linear-gradient(to right,
{'#0000FF'}, {'#3399FF'} {20}%,
{'#3399FF'} {20}%, {'#66CCFF'} {40}%,
{'#66CCFF'} {40}%, {'#FFFFFF'} {50}%,
{'#FFFFFF'} {50}%, {'#FF66CC'} {80}%,
{'#FF66CC'} {80}%, {'#FF3399'}); height: 10px;"></div>
</div>
'''
# Display the legend and caption on the map
aoi_map_bbox.get_root().html.add_child(folium.Element(legend_html))
# Add the title to the map
= '''
title_html <div style="position: fixed; top: 10px; right: 10px; z-index: 1000; background-color: rgba(255, 255, 255, 0.8); border-radius: 5px; border: 1px solid grey; padding: 10px;">
<b>Air-Sea CO₂ Flux, ECCO-Darwin</b><br>
September 2022
</div>
'''
# Display the title on the map
aoi_map_bbox.get_root().html.add_child(folium.Element(title_html))
# Visualize the map
aoi_map_bbox
Summary
In this notebook we have successfully completed the following steps for the STAC collection for the NASA Air-Sea CO₂ Flux ECCO Darwin dataset: 1. Install and import the necessary libraries 2. Fetch the collection from STAC collections using the appropriate endpoints 3. Count the number of existing granules within the collection 4. Map and compare the CO₂ Flux levels over the Coastal California area for two distinctive months/years 5. Create a table that displays the minimum, maximum, and sum of the CO₂ Flux values for a specified region 6. Generate a time-series graph of the CO₂ Flux values for a specified region
If you have any questions regarding this user notebook, please contact us using the feedback form.