Vulcan Fossil Fuel CO₂ Emissions

Annual (2010 - 2021), 1 km resolution estimates of carbon dioxide emissions from fossil fuels and cement production over the contiguous United States, version 4.0.
Author

Siddharth Chaudhary, Paridhi Parajuli

Published

August 30, 2024

Run this notebook

You can launch this notebook in the US GHG Center JupyterHub by clicking the link below.

Launch in the US GHG Center JupyterHub (requires access)

Approach

  1. 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 Vulcan Fossil Fuel CO₂ Emissions Data product.
  2. Pass the STAC item into the raster API /collections/{collection_id}/items/{item_id}/tilejson.json endpoint.
  3. Using folium.plugins.DualMap, we will visualize two tiles (side-by-side), allowing us to compare time points.
  4. After the visualization, we will perform zonal statistics for a given polygon.

About the Data

The Vulcan version 4.0 data product represents total carbon dioxide (CO2) emissions resulting from the combustion of fossil fuel (ff) for the contiguous United States and District of Columbia. Referred to as ffCO2, the emissions from Vulcan are also categorized into 10 source sectors including; airports, cement production, commercial marine vessels, commercial, power plants, industrial, non-road, on-road, residential and railroads. Data are gridded annually on a 1-km grid for the years 2010 to 2021. These data are annual sums of hourly estimates. Shown is the estimated total annual ffCO2 for the United States, as well as the estimated total annual ffCO2 per sector.

For more information regarding this dataset, please visit the Vulcan Fossil Fuel CO₂ Emissions, Version 4 data overview page.

Install the Required Libraries

Required libraries are pre-installed on the GHG Center Hub. If you need to run this notebook elsewhere, please install them with this line in a code cell:

%pip install requests folium rasterstats pystac_client pandas matplotlib –quiet

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
/Users/rrimal/Library/Python/3.9/lib/python/site-packages/urllib3/__init__.py:35: NotOpenSSLWarning: urllib3 v2 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020
  warnings.warn(

Querying the STAC API

First, we are going to import the required libraries. Once imported, they allow better executing a query in the GHG Center Spatio Temporal Asset Catalog (STAC) Application Programming Interface (API) where the granules for this collection are stored.

# Provide STAC and RASTER API endpoints
STAC_API_URL = "https://earth.gov/ghgcenter/api/stac"
RASTER_API_URL = "https://earth.gov/ghgcenter/api/raster"

# Please use the collection name similar to the one used in the STAC collection.
# Name of the collection for Vulcan Fossil Fuel CO₂ Emissions, Version 4. 
collection_name = "vulcan-ffco2-yeargrid-v4"
# Fetch the collection from STAC collections using the appropriate endpoint
# the 'requests' library allows a HTTP request possible
collection_vulcan = requests.get(f"{STAC_API_URL}/collections/{collection_name}").json()

Examining the contents of our collection under the temporal variable, we see that the data is available from January 2010 to December 2021. By looking at the dashboard:time density, we observe that the data is periodic with year time density.

collection_vulcan
{'id': 'vulcan-ffco2-yeargrid-v4',
 'type': 'Collection',
 'links': [{'rel': 'items',
   'type': 'application/geo+json',
   'href': 'https://earth.gov/ghgcenter/api/stac/collections/vulcan-ffco2-yeargrid-v4/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/vulcan-ffco2-yeargrid-v4'}],
 'title': 'Vulcan Fossil Fuel CO₂ Emissions v4.0',
 'extent': {'spatial': {'bbox': [[-128.22654896758996,
     22.857766529124284,
     -65.30917199495289,
     51.44087947724907]]},
  'temporal': {'interval': [['2010-01-01 00:00:00+00',
     '2021-12-31 00:00:00+00']]}},
 'license': 'CC-BY-NC-4.0',
 'renders': {'air-co2': {'assets': ['air-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'cmt-co2': {'assets': ['cmt-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'cmv-co2': {'assets': ['cmv-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'com-co2': {'assets': ['com-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'elc-co2': {'assets': ['elc-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'ind-co2': {'assets': ['ind-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'nrd-co2': {'assets': ['nrd-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'onr-co2': {'assets': ['onr-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'res-co2': {'assets': ['res-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'rrd-co2': {'assets': ['rrd-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'dashboard': {'assets': ['total-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'},
  'total-co2': {'assets': ['total-co2'],
   'rescale': [[0, 500]],
   'colormap_name': 'spectral_r'}},
 'providers': [{'url': 'https://vulcan.rc.nau.edu/',
   'name': 'North American Carbon Program',
   'roles': ['producer', 'licensor']}],
 'summaries': {'datetime': ['2010-01-01T00:00:00Z', '2021-12-31T00:00:00Z']},
 'description': 'Annual (2010 - 2021), 1 km resolution estimates of carbon dioxide emissions from fossil fuels and cement production over the contiguous United States, version 4.0',
 'item_assets': {'air-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Airport Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from taxi, take-off, and landing up to 3000 ft.'},
  'cmt-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Cement Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from cement production.'},
  'cmv-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Commercial Marine Vessel Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from commercial marine vessels while maneuvering, hoteling, cruising and traveling within reduced speed zones at ports and shipping lanes. Includes only activity within 12 nautical miles (~22km) from the U.S. shoreline.'},
  'com-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Commercial Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from Commercial buildings.'},
  'elc-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Power Plant Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from power plants.'},
  'ind-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Industrial Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from Industrial buildings.'},
  'nrd-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Non-Road Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from off-road engines, equipment and vehicles including waterborne pleasure craft.'},
  'onr-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'On-Road Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from mobile vehicles on roads.'},
  'res-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Residential Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual ffCO₂ emissions from Residential buildings.'},
  'rrd-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Railroad Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual FFCO₂ emissions coming from railroads.'},
  'total-co2': {'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
   'roles': ['data', 'layer'],
   'title': 'Total Fossil Fuel CO₂ Emissions',
   'description': 'Estimated total annual CO₂ emissions from fossil fuel combustion (ffCO₂) across all sectors..'}},
 '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': 'year'}
# Create a function that would search for the above data collection in the STAC API
def get_item_count(collection_id):
    count = 0
    items_url = f"{STAC_API_URL}/collections/{collection_id}/items"

    while True:
        response = requests.get(items_url)

        if not response.ok:
            print("error getting items")
            exit()

        stac = response.json()
        count += int(stac["context"].get("returned", 0))
        next = [link for link in stac["links"] if link["rel"] == "next"]

        if not next:
            break
        items_url = next[0]["href"]

    return count
# Apply the above function and check the total number of items available within the collection
number_of_items = get_item_count(collection_name)
items_vulcan = requests.get(f"{STAC_API_URL}/collections/{collection_name}/items?limit={number_of_items}").json()["features"]
print(f"Found {len(items_vulcan)} items")
Found 12 items
# Examine the first item in the collection
# Keep in mind that a list starts from 0, 1, 2... therefore items[0] is referring to the first item in the list/collection
items_vulcan[0]
{'id': 'vulcan-ffco2-yeargrid-v4-2021',
 'bbox': [-128.22654896758996,
  22.857766529124284,
  -65.30917199495289,
  51.44087947724907],
 'type': 'Feature',
 'links': [{'rel': 'collection',
   'type': 'application/json',
   'href': 'https://earth.gov/ghgcenter/api/stac/collections/vulcan-ffco2-yeargrid-v4'},
  {'rel': 'parent',
   'type': 'application/json',
   'href': 'https://earth.gov/ghgcenter/api/stac/collections/vulcan-ffco2-yeargrid-v4'},
  {'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/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021'},
  {'title': 'Map of Item',
   'href': 'https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021/map?assets=total-co2&rescale=0%2C500&colormap_name=spectral_r',
   'rel': 'preview',
   'type': 'text/html'}],
 'assets': {'air-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/AIR_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Airport CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from taxi, take-off, and landing up to 3000 ft.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 318726.1875,
      'min': 0.11889950931072235,
      'count': 11,
      'buckets': [14659, 40, 6, 2, 4, 0, 2, 0, 0, 1]},
     'statistics': {'mean': 1190.7966562457523,
      'stddev': 5906.230747537605,
      'maximum': 318726.1875,
      'minimum': 0.11889950931072235,
      'valid_percent': 3.083506571888412}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'cmt-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/CMT_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Cement CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from cement production.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 538037.5,
      'min': 14599.9677734375,
      'count': 11,
      'buckets': [10, 15, 19, 7, 9, 4, 4, 6, 0, 1]},
     'statistics': {'mean': 181749.84,
      'stddev': 114981.70564725697,
      'maximum': 538037.5,
      'minimum': 14599.9677734375,
      'valid_percent': 0.015717207618025753}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'cmv-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/CMV_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Commercial Marine Vessels CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from commercial marine vessels while maneuvering, hoteling, cruising and traveling within reduced speed zones at ports and shipping lanes. Includes only activity within 12 nautical miles (~22km) from the U.S. shoreline.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 15446.8408203125,
      'min': 8.111214810924139e-07,
      'count': 11,
      'buckets': [17370, 16, 5, 1, 2, 0, 1, 0, 0, 1]},
     'statistics': {'mean': 32.60311997010807,
      'stddev': 210.77205857399764,
      'maximum': 15446.8408203125,
      'minimum': 8.111214810924139e-07,
      'valid_percent': 3.6455539163090127}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'com-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/COM_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Commercial CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Commercial buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 41811.0625,
      'min': 6.441725486361349e-10,
      'count': 11,
      'buckets': [178117, 7, 1, 1, 0, 0, 1, 0, 0, 2]},
     'statistics': {'mean': 10.866918777964285,
      'stddev': 175.08472372009805,
      'maximum': 41811.0625,
      'minimum': 6.441725486361349e-10,
      'valid_percent': 37.32920634388412}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'elc-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/ELC_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Powerplants CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from power plants.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 5685384.0,
      'min': 1.3666567610925995e-05,
      'count': 11,
      'buckets': [3813, 90, 29, 26, 8, 8, 6, 2, 0, 1]},
     'statistics': {'mean': 94311.64850615115,
      'stddev': 355198.87374596845,
      'maximum': 5685384.0,
      'minimum': 1.3666567610925995e-05,
      'valid_percent': 0.8346885059012876}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'ind-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/IND_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Industrial CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Industrial buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 3248811.0,
      'min': 7.467048507292517e-11,
      'count': 11,
      'buckets': [110441, 0, 0, 0, 0, 0, 0, 0, 0, 1]},
     'statistics': {'mean': 120.20799152496333,
      'stddev': 9843.60430747931,
      'maximum': 3248811.0,
      'minimum': 7.467048507292517e-11,
      'valid_percent': 23.14453125}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'nrd-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/NRD_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Nonroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from off-road engines, equipment and vehicles including waterborne pleasure craft.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 2277.109619140625,
      'min': 1.7788032380394725e-07,
      'count': 11,
      'buckets': [227435, 26, 5, 1, 0, 1, 1, 0, 0, 2]},
     'statistics': {'mean': 6.1029197128425166,
      'stddev': 14.197089191407585,
      'maximum': 2277.109619140625,
      'minimum': 1.7788032380394725e-07,
      'valid_percent': 47.66945245439914}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'onr-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/ONR_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Onroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from mobile vehicles on roads.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 16120.27734375,
      'min': 0.0011055185459554195,
      'count': 11,
      'buckets': [195583, 803, 88, 22, 3, 2, 0, 0, 0, 1]},
     'statistics': {'mean': 64.57338856601969,
      'stddev': 230.03362908149538,
      'maximum': 16120.27734375,
      'minimum': 0.0011055185459554195,
      'valid_percent': 41.179503084763944}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'res-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/RES_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Residential CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Residential buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 10387.0556640625,
      'min': 9.804268508162295e-09,
      'count': 11,
      'buckets': [204532, 112, 28, 7, 4, 3, 3, 2, 1, 1]},
     'statistics': {'mean': 12.793920651903093,
      'stddev': 91.07716732362586,
      'maximum': 10387.0556640625,
      'minimum': 9.804268508162295e-09,
      'valid_percent': 42.896031719420606}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'rrd-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/RRD_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Railroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions coming from railroads.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 4935.501953125,
      'min': 7.793863915139809e-05,
      'count': 11,
      'buckets': [43982, 167, 38, 9, 7, 5, 3, 2, 1, 2]},
     'statistics': {'mean': 24.959290754478015,
      'stddev': 94.2219837346061,
      'maximum': 4935.501953125,
      'minimum': 7.793863915139809e-05,
      'valid_percent': 9.266027360515022}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'total-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/TOT_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total of all sectors CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual CO₂ emissions from fossil fuel combustion (ffCO₂) across all sectors.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 272530.15625,
      'min': 1.7858106104995386e-07,
      'count': 11,
      'buckets': [227843, 81, 36, 7, 3, 6, 1, 4, 1, 1]},
     'statistics': {'mean': 162.91311194255712,
      'stddev': 2080.549384731812,
      'maximum': 272530.15625,
      'minimum': 1.7858106104995386e-07,
      'valid_percent': 47.7767485917382}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'rendered_preview': {'title': 'Rendered preview',
   'href': 'https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021/preview.png?assets=total-co2&rescale=0%2C500&colormap_name=spectral_r',
   'rel': 'preview',
   'roles': ['overview'],
   'type': 'image/png'}},
 'geometry': {'type': 'Polygon',
  'coordinates': [[[-128.22654896758996, 22.857766529124284],
    [-65.30917199495289, 22.857766529124284],
    [-65.30917199495289, 51.44087947724907],
    [-128.22654896758996, 51.44087947724907],
    [-128.22654896758996, 22.857766529124284]]]},
 'collection': 'vulcan-ffco2-yeargrid-v4',
 'properties': {'end_datetime': '2021-12-31T00:00:00+00:00',
  'start_datetime': '2021-01-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']}
# To access the year value from each item more easily, this will let us query more explicitly by year and month (e.g., 2020-02)
items = {item["properties"]["start_datetime"][:4]: item for item in items_vulcan} 
# rh = Heterotrophic Respiration
asset_name = "total-co2"
rescale_values = {"max":items[list(items.keys())[0]]["assets"][asset_name]["raster:bands"][0]["histogram"]["max"], "min":items[list(items.keys())[0]]["assets"][asset_name]["raster:bands"][0]["histogram"]["min"]}

Now, we will pass the item id, collection name, asset name, and the rescaling factor to the Raster API endpoint. We will do this twice, once for 2021 and again for 2010, so that we can visualize each event independently.

color_map = "spectral_r" # please refer to matplotlib library if you'd prefer choosing a different color ramp.
# For more information on Colormaps in Matplotlib, please visit https://matplotlib.org/stable/users/explain/colors/colormaps.html

# To change the year and month of the observed parameter, you can modify the "items['YYYY-MM']" statement
# For example, you can change the current statement "items['2003-12']" to "items['2016-10']" 
_2021_tile = requests.get(
    f"{RASTER_API_URL}/collections/{items['2021']['collection']}/items/{items['2021']['id']}/tilejson.json?"
    f"&assets={asset_name}"
    f"&color_formula=gamma+r+1.05&colormap_name={color_map}"
    f"&rescale=0,150", 
).json()
_2021_tile
{'tilejson': '2.2.0',
 'version': '1.0.0',
 'scheme': 'xyz',
 'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=total-co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],
 'minzoom': 0,
 'maxzoom': 24,
 'bounds': [-128.22654896758996,
  22.857766529124284,
  -65.30917199495289,
  51.44087947724907],
 'center': [-96.76786048127143, 37.14932300318668, 0]}
_2010_tile = requests.get(
    f"{RASTER_API_URL}/collections/{items['2010']['collection']}/items/{items['2010']['id']}/tilejson.json?"

    f"&assets={asset_name}"
    f"&color_formula=gamma+r+1.05&colormap_name={color_map}"
    f"&rescale=0,150", 
).json()
_2010_tile
{'tilejson': '2.2.0',
 'version': '1.0.0',
 'scheme': 'xyz',
 'tiles': ['https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2010/tiles/WebMercatorQuad/{z}/{x}/{y}@1x?assets=total-co2&color_formula=gamma+r+1.05&colormap_name=spectral_r&rescale=0%2C150'],
 'minzoom': 0,
 'maxzoom': 24,
 'bounds': [-128.22654896758996,
  22.857766529124284,
  -65.30917199495289,
  51.44087947724907],
 'center': [-96.76786048127143, 37.14932300318668, 0]}

Visualizing Total Fossil Fuel CO₂ Emissions

map_ = folium.plugins.DualMap(location=(34, -118), zoom_start=6)


# Define the first map layer with the CO2 Flux data for December 2022
map_layer_2021 = TileLayer(
    tiles=_2021_tile["tiles"][0], # Path to retrieve the tile
    attr="GHG", # Set the attribution 
    name='2021 Total CO2 Fossil Fuel Emissions', # Title for the layer
    overlay=True, # The layer can be overlaid on the map
    opacity=0.8, # Adjust the transparency of the layer
)
# Add the first layer to the Dual Map 
map_layer_2021.add_to(map_.m1)

map_layer_2010 = TileLayer(
    tiles=_2010_tile["tiles"][0], # Path to retrieve the tile
    attr="GHG", # Set the attribution 
    name='2010 Total CO2 Fossil Fuel Emissions', # Title for the layer
    overlay=True, # The layer can be overlaid on the map
    opacity=0.8, # Adjust the transparency of the layer
)
# Add the first layer to the Dual Map 
map_layer_2010.add_to(map_.m2)

map_
Make this Notebook Trusted to load map: File -> Trust Notebook

Calculating Zonal Statistics

To perform zonal statistics, first we need to create a polygon. In this use case we are creating a polygon in Texas (USA).

# Create a polygon for the area of interest (aoi)
texas_aoi = {
    "type": "Feature", # Create a feature object
    "properties": {},
    "geometry": { # Set the bounding coordinates for the polygon
        "coordinates": [
            [
                [-95, 29], # South-east bounding coordinate
                [-95, 33], # North-east bounding coordinate
                [-104,33], # North-west bounding coordinate
                [-104,29], # South-west bounding coordinate
                [-95, 29]  # South-east bounding coordinate (closing the polygon)
            ]
        ],
        "type": "Polygon",
    },
}
# Create a new map to display the generated polygon
# We'll plug in the coordinates for a location
# Central to the study area and a reasonable zoom level
aoi_map = Map(

    # Base map is set to OpenStreetMap
    tiles="OpenStreetMap",

    # Define the spatial properties for the map
    location=[
        30,-100
    ],

    # Set the zoom value
    zoom_start=6,
)

# Insert the polygon to the map
folium.GeoJson(texas_aoi, name="Texas, USA").add_to(aoi_map)

# Visualize the map
aoi_map
Make this Notebook Trusted to load map: File -> Trust Notebook
# Check total number of items available within the collection
items = requests.get(
    f"{STAC_API_URL}/collections/{collection_name}/items?limit=600"
).json()["features"]

# Print the total number of items (granules) found
print(f"Found {len(items)} items")
Found 12 items
# Examine the first item in the collection
items[0]
{'id': 'vulcan-ffco2-yeargrid-v4-2021',
 'bbox': [-128.22654896758996,
  22.857766529124284,
  -65.30917199495289,
  51.44087947724907],
 'type': 'Feature',
 'links': [{'rel': 'collection',
   'type': 'application/json',
   'href': 'https://earth.gov/ghgcenter/api/stac/collections/vulcan-ffco2-yeargrid-v4'},
  {'rel': 'parent',
   'type': 'application/json',
   'href': 'https://earth.gov/ghgcenter/api/stac/collections/vulcan-ffco2-yeargrid-v4'},
  {'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/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021'},
  {'title': 'Map of Item',
   'href': 'https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021/map?assets=total-co2&rescale=0%2C500&colormap_name=spectral_r',
   'rel': 'preview',
   'type': 'text/html'}],
 'assets': {'air-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/AIR_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Airport CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from taxi, take-off, and landing up to 3000 ft.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 318726.1875,
      'min': 0.11889950931072235,
      'count': 11,
      'buckets': [14659, 40, 6, 2, 4, 0, 2, 0, 0, 1]},
     'statistics': {'mean': 1190.7966562457523,
      'stddev': 5906.230747537605,
      'maximum': 318726.1875,
      'minimum': 0.11889950931072235,
      'valid_percent': 3.083506571888412}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'cmt-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/CMT_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Cement CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from cement production.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 538037.5,
      'min': 14599.9677734375,
      'count': 11,
      'buckets': [10, 15, 19, 7, 9, 4, 4, 6, 0, 1]},
     'statistics': {'mean': 181749.84,
      'stddev': 114981.70564725697,
      'maximum': 538037.5,
      'minimum': 14599.9677734375,
      'valid_percent': 0.015717207618025753}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'cmv-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/CMV_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Commercial Marine Vessels CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from commercial marine vessels while maneuvering, hoteling, cruising and traveling within reduced speed zones at ports and shipping lanes. Includes only activity within 12 nautical miles (~22km) from the U.S. shoreline.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 15446.8408203125,
      'min': 8.111214810924139e-07,
      'count': 11,
      'buckets': [17370, 16, 5, 1, 2, 0, 1, 0, 0, 1]},
     'statistics': {'mean': 32.60311997010807,
      'stddev': 210.77205857399764,
      'maximum': 15446.8408203125,
      'minimum': 8.111214810924139e-07,
      'valid_percent': 3.6455539163090127}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'com-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/COM_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Commercial CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Commercial buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 41811.0625,
      'min': 6.441725486361349e-10,
      'count': 11,
      'buckets': [178117, 7, 1, 1, 0, 0, 1, 0, 0, 2]},
     'statistics': {'mean': 10.866918777964285,
      'stddev': 175.08472372009805,
      'maximum': 41811.0625,
      'minimum': 6.441725486361349e-10,
      'valid_percent': 37.32920634388412}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'elc-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/ELC_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Powerplants CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from power plants.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 5685384.0,
      'min': 1.3666567610925995e-05,
      'count': 11,
      'buckets': [3813, 90, 29, 26, 8, 8, 6, 2, 0, 1]},
     'statistics': {'mean': 94311.64850615115,
      'stddev': 355198.87374596845,
      'maximum': 5685384.0,
      'minimum': 1.3666567610925995e-05,
      'valid_percent': 0.8346885059012876}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'ind-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/IND_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Industrial CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Industrial buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 3248811.0,
      'min': 7.467048507292517e-11,
      'count': 11,
      'buckets': [110441, 0, 0, 0, 0, 0, 0, 0, 0, 1]},
     'statistics': {'mean': 120.20799152496333,
      'stddev': 9843.60430747931,
      'maximum': 3248811.0,
      'minimum': 7.467048507292517e-11,
      'valid_percent': 23.14453125}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'nrd-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/NRD_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Nonroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from off-road engines, equipment and vehicles including waterborne pleasure craft.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 2277.109619140625,
      'min': 1.7788032380394725e-07,
      'count': 11,
      'buckets': [227435, 26, 5, 1, 0, 1, 1, 0, 0, 2]},
     'statistics': {'mean': 6.1029197128425166,
      'stddev': 14.197089191407585,
      'maximum': 2277.109619140625,
      'minimum': 1.7788032380394725e-07,
      'valid_percent': 47.66945245439914}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'onr-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/ONR_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Onroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from mobile vehicles on roads.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 16120.27734375,
      'min': 0.0011055185459554195,
      'count': 11,
      'buckets': [195583, 803, 88, 22, 3, 2, 0, 0, 0, 1]},
     'statistics': {'mean': 64.57338856601969,
      'stddev': 230.03362908149538,
      'maximum': 16120.27734375,
      'minimum': 0.0011055185459554195,
      'valid_percent': 41.179503084763944}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'res-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/RES_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Residential CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions from Residential buildings.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 10387.0556640625,
      'min': 9.804268508162295e-09,
      'count': 11,
      'buckets': [204532, 112, 28, 7, 4, 3, 3, 2, 1, 1]},
     'statistics': {'mean': 12.793920651903093,
      'stddev': 91.07716732362586,
      'maximum': 10387.0556640625,
      'minimum': 9.804268508162295e-09,
      'valid_percent': 42.896031719420606}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'rrd-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/RRD_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total Railroad CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual ffCO₂ emissions coming from railroads.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 4935.501953125,
      'min': 7.793863915139809e-05,
      'count': 11,
      'buckets': [43982, 167, 38, 9, 7, 5, 3, 2, 1, 2]},
     'statistics': {'mean': 24.959290754478015,
      'stddev': 94.2219837346061,
      'maximum': 4935.501953125,
      'minimum': 7.793863915139809e-05,
      'valid_percent': 9.266027360515022}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'total-co2': {'href': 's3://ghgc-data-store/vulcan-ffco2-yeargrid-v4/TOT_CO2_USA_mosaic_grid_1km_mn_2021.tif',
   'type': 'image/tiff; application=geotiff',
   'roles': ['data', 'layer'],
   'title': 'Total of all sectors CO₂ Emissions',
   'proj:bbox': [-128.22654896758996,
    22.857766529124284,
    -65.30917199495289,
    51.44087947724907],
   'proj:epsg': 4326,
   'proj:wkt2': 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]',
   'proj:shape': [2649, 5831],
   'description': 'Estimated total annual CO₂ emissions from fossil fuel combustion (ffCO₂) across all sectors.',
   'raster:bands': [{'scale': 1.0,
     'nodata': -9999.0,
     'offset': 0.0,
     'sampling': 'area',
     'data_type': 'float32',
     'histogram': {'max': 272530.15625,
      'min': 1.7858106104995386e-07,
      'count': 11,
      'buckets': [227843, 81, 36, 7, 3, 6, 1, 4, 1, 1]},
     'statistics': {'mean': 162.91311194255712,
      'stddev': 2080.549384731812,
      'maximum': 272530.15625,
      'minimum': 1.7858106104995386e-07,
      'valid_percent': 47.7767485917382}}],
   'proj:geometry': {'type': 'Polygon',
    'coordinates': [[[-128.22654896758996, 22.857766529124284],
      [-65.30917199495289, 22.857766529124284],
      [-65.30917199495289, 51.44087947724907],
      [-128.22654896758996, 51.44087947724907],
      [-128.22654896758996, 22.857766529124284]]]},
   'proj:projjson': {'id': {'code': 4326, 'authority': 'EPSG'},
    'name': 'WGS 84',
    'type': 'GeographicCRS',
    'datum': {'name': 'World Geodetic System 1984',
     'type': 'GeodeticReferenceFrame',
     'ellipsoid': {'name': 'WGS 84',
      'semi_major_axis': 6378137,
      'inverse_flattening': 298.257223563}},
    '$schema': 'https://proj.org/schemas/v0.7/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.01079015211329739,
    0.0,
    -128.22654896758996,
    0.0,
    -0.01079015211329739,
    51.44087947724907,
    0.0,
    0.0,
    1.0]},
  'rendered_preview': {'title': 'Rendered preview',
   'href': 'https://earth.gov/ghgcenter/api/raster/collections/vulcan-ffco2-yeargrid-v4/items/vulcan-ffco2-yeargrid-v4-2021/preview.png?assets=total-co2&rescale=0%2C500&colormap_name=spectral_r',
   'rel': 'preview',
   'roles': ['overview'],
   'type': 'image/png'}},
 'geometry': {'type': 'Polygon',
  'coordinates': [[[-128.22654896758996, 22.857766529124284],
    [-65.30917199495289, 22.857766529124284],
    [-65.30917199495289, 51.44087947724907],
    [-128.22654896758996, 51.44087947724907],
    [-128.22654896758996, 22.857766529124284]]]},
 'collection': 'vulcan-ffco2-yeargrid-v4',
 'properties': {'end_datetime': '2021-12-31T00:00:00+00:00',
  'start_datetime': '2021-01-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']}

Now that we created the polygon for the area of interest, we 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
    result = requests.post(

        # 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
        params={"url": item["assets"][asset_name]["href"]},

        # Send the GeoJSON object (polygon) along with the request
        json=geojson,

    # 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"][:10],
    }
# 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"][:10])

    # Exit the loop after printing the start datetime for the first item in the collection
    break
2021-01-01

With the function above we can 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 polygon
stats = [generate_stats(item, texas_aoi) for item in items]
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.7858106104995386e-07, 'max': 3768974.0, 'mean': 261.6907958984375, 'count': 296120.0625, 'sum': 77491896.0, 'std': 11522.940944047226, 'median': 7.39058256149292, 'majority': 0.19903208315372467, 'minority': 1.7858106104995386e-07, 'unique': 242084.0, 'histogram': [[296498.0, 13.0, 6.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0], [1.7858106104995386e-07, 376897.40625, 753794.8125, 1130692.25, 1507589.625, 1884487.0, 2261384.5, 2638281.75, 3015179.25, 3392076.75, 3768974.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.20036202669143677, 'percentile_98': 1811.0848388671875}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.6228801769102574e-07, 'max': 3548930.5, 'mean': 254.9629364013672, 'count': 296120.0625, 'sum': 75499640.0, 'std': 10912.768301398139, 'median': 6.836727142333984, 'majority': 0.18084532022476196, 'minority': 1.6228801769102574e-07, 'unique': 242118.0, 'histogram': [[296495.0, 14.0, 6.0, 2.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0], [1.6228801769102574e-07, 354893.0625, 709786.125, 1064679.25, 1419572.25, 1774465.25, 2129358.5, 2484251.5, 2839144.5, 3194037.5, 3548930.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.1822243481874466, 'percentile_98': 1713.1064453125}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.8778726484924846e-07, 'max': 3369803.0, 'mean': 276.8847961425781, 'count': 296120.0625, 'sum': 81991144.0, 'std': 11799.911186106445, 'median': 7.814598083496094, 'majority': 0.5271552801132202, 'minority': 1.8778726484924846e-07, 'unique': 242967.0, 'histogram': [[296495.0, 13.0, 6.0, 3.0, 0.0, 0.0, 0.0, 1.0, 0.0, 2.0], [1.8778726484924846e-07, 336980.3125, 673960.625, 1010940.9375, 1347921.25, 1684901.5, 2021881.875, 2358862.25, 2695842.5, 3032822.75, 3369803.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.2122441828250885, 'percentile_98': 1882.463623046875}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.8530673173700052e-07, 'max': 3868559.5, 'mean': 278.5229797363281, 'count': 296120.0625, 'sum': 82476240.0, 'std': 12222.416782289827, 'median': 7.711860179901123, 'majority': 0.5199297666549683, 'minority': 1.8530673173700052e-07, 'unique': 242928.0, 'histogram': [[296497.0, 14.0, 6.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0], [1.8530673173700052e-07, 386855.9375, 773711.875, 1160567.75, 1547423.75, 1934279.75, 2321135.5, 2707991.5, 3094847.5, 3481703.5, 3868559.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.20897679030895233, 'percentile_98': 1912.632568359375}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.802979596732257e-07, 'max': 4050962.5, 'mean': 271.1694030761719, 'count': 296120.0625, 'sum': 80298704.0, 'std': 13290.47237685704, 'median': 7.44655704498291, 'majority': 0.5057953596115112, 'minority': 1.802979596732257e-07, 'unique': 242922.0, 'histogram': [[296499.0, 14.0, 3.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0], [1.802979596732257e-07, 405096.25, 810192.5, 1215288.75, 1620385.0, 2025481.25, 2430577.5, 2835673.75, 3240770.0, 3645866.25, 4050962.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.20326974987983704, 'percentile_98': 1775.7847900390625}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.7791849415971228e-07, 'max': 3638032.0, 'mean': 267.9085693359375, 'count': 296120.0625, 'sum': 79333104.0, 'std': 12285.331741552607, 'median': 7.373904228210449, 'majority': 0.49914538860321045, 'minority': 1.7791849415971228e-07, 'unique': 242963.0, 'histogram': [[296494.0, 15.0, 6.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0], [1.7791849415971228e-07, 363803.1875, 727606.375, 1091409.5, 1455212.75, 1819016.0, 2182819.0, 2546622.25, 2910425.5, 3274228.75, 3638032.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.20115220546722412, 'percentile_98': 1766.38818359375}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 2.130747986939241e-07, 'max': 4168191.0, 'mean': 272.1916809082031, 'count': 296120.0625, 'sum': 80601416.0, 'std': 13148.255549691754, 'median': 8.486613273620605, 'majority': 0.5976722836494446, 'minority': 2.130747986939241e-07, 'unique': 242958.0, 'histogram': [[296498.0, 15.0, 3.0, 0.0, 0.0, 2.0, 0.0, 1.0, 0.0, 1.0], [2.130747986939241e-07, 416819.09375, 833638.1875, 1250457.25, 1667276.375, 2084095.5, 2500914.5, 2917733.75, 3334552.75, 3751371.75, 4168191.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.24038611352443695, 'percentile_98': 1771.21240234375}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 2.0937106626206514e-07, 'max': 4368415.0, 'mean': 266.218017578125, 'count': 296120.0625, 'sum': 78832496.0, 'std': 13696.474874945012, 'median': 8.353293418884277, 'majority': 0.5873664617538452, 'minority': 2.0937106626206514e-07, 'unique': 242943.0, 'histogram': [[296501.0, 12.0, 3.0, 0.0, 1.0, 0.0, 0.0, 2.0, 0.0, 1.0], [2.0937106626206514e-07, 436841.5, 873683.0, 1310524.5, 1747366.0, 2184207.5, 2621049.0, 3057890.5, 3494732.0, 3931573.5, 4368415.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.23638056218624115, 'percentile_98': 1761.578857421875}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.949561152514434e-07, 'max': 4275952.5, 'mean': 260.8044128417969, 'count': 296120.0625, 'sum': 77229416.0, 'std': 13665.846479453807, 'median': 7.816947937011719, 'majority': 0.5478244423866272, 'minority': 1.949561152514434e-07, 'unique': 243001.0, 'histogram': [[296501.0, 11.0, 4.0, 0.0, 0.0, 1.0, 0.0, 2.0, 0.0, 1.0], [1.949561152514434e-07, 427595.25, 855190.5, 1282785.75, 1710381.0, 2137976.25, 2565571.5, 2993166.75, 3420762.0, 3848357.25, 4275952.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.22091242671012878, 'percentile_98': 1687.38818359375}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.8786006705795444e-07, 'max': 3873315.0, 'mean': 251.08050537109375, 'count': 296120.0625, 'sum': 74349976.0, 'std': 12656.74018063103, 'median': 7.482449054718018, 'majority': 0.5272803902626038, 'minority': 1.8786006705795444e-07, 'unique': 242919.0, 'histogram': [[296500.0, 12.0, 3.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0], [1.8786006705795444e-07, 387331.5, 774663.0, 1161994.5, 1549326.0, 1936657.5, 2323989.0, 2711320.5, 3098652.0, 3485983.5, 3873315.0]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.212051123380661, 'percentile_98': 1615.6910400390625}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.9114715144041838e-07, 'max': 4798060.5, 'mean': 255.62869262695312, 'count': 296120.0625, 'sum': 75696784.0, 'std': 14444.495145210165, 'median': 7.578545093536377, 'majority': 0.5363049507141113, 'minority': 1.9114715144041838e-07, 'unique': 242933.0, 'histogram': [[296505.0, 10.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0], [1.9114715144041838e-07, 479806.0625, 959612.125, 1439418.25, 1919224.25, 2399030.25, 2878836.5, 3358642.5, 3838448.5, 4318254.5, 4798060.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.21587365865707397, 'percentile_98': 1612.6146240234375}}}}
{'type': 'Feature', 'geometry': {'type': 'Polygon', 'coordinates': [[[-95.0, 29.0], [-95.0, 33.0], [-104.0, 33.0], [-104.0, 29.0], [-95.0, 29.0]]]}, 'properties': {'statistics': {'b1': {'min': 1.898683592571615e-07, 'max': 4486994.5, 'mean': 243.4835662841797, 'count': 296120.0625, 'sum': 72100368.0, 'std': 13255.782134600735, 'median': 7.461791038513184, 'majority': 0.5328000783920288, 'minority': 1.898683592571615e-07, 'unique': 239140.0, 'histogram': [[296505.0, 10.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0], [1.898683592571615e-07, 448699.4375, 897398.875, 1346098.25, 1794797.75, 2243497.25, 2692196.5, 3140896.0, 3589595.5, 4038295.0, 4486994.5]], 'valid_percent': 95.72, 'masked_pixels': 13265.0, 'valid_pixels': 296520.0, 'percentile_2': 0.2142595797777176, 'percentile_98': 1595.547119140625}}}}
CPU times: user 92.6 ms, sys: 21 ms, total: 114 ms
Wall time: 23.5 s

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.

# Print the stats for the first item in the collection
stats[0]
{'statistics': {'b1': {'min': 1.7858106104995386e-07,
   'max': 3768974.0,
   'mean': 261.6907958984375,
   'count': 296120.0625,
   'sum': 77491896.0,
   'std': 11522.940944047226,
   'median': 7.39058256149292,
   'majority': 0.19903208315372467,
   'minority': 1.7858106104995386e-07,
   'unique': 242084.0,
   'histogram': [[296498.0, 13.0, 6.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 2.0],
    [1.7858106104995386e-07,
     376897.40625,
     753794.8125,
     1130692.25,
     1507589.625,
     1884487.0,
     2261384.5,
     2638281.75,
     3015179.25,
     3392076.75,
     3768974.0]],
   'valid_percent': 95.72,
   'masked_pixels': 13265.0,
   'valid_pixels': 296520.0,
   'percentile_2': 0.20036202669143677,
   'percentile_98': 1811.0848388671875}},
 'datetime': '2021-01-01'}
# Create a function that converts statistics in JSON format into a pandas DataFrame
def clean_stats(stats_json) -> pd.DataFrame:

    # Normalize the JSON data
    df = pd.json_normalize(stats_json)

    # Replace the naming "statistics.b1" in the columns
    df.columns = [col.replace("statistics.b1.", "") for col in df.columns]

    # Set the datetime format
    df["date"] = pd.to_datetime(df["datetime"])

    # Return the cleaned format
    return df

# Apply the generated function on the stats data
df = clean_stats(stats)

# 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
df.head(5)
datetime min max mean count sum std median majority minority unique histogram valid_percent masked_pixels valid_pixels percentile_2 percentile_98 date
0 2021-01-01 1.785811e-07 3768974.0 261.690796 296120.0625 77491896.0 11522.940944 7.390583 0.199032 1.785811e-07 242084.0 [[296498.0, 13.0, 6.0, 0.0, 1.0, 0.0, 0.0, 0.0... 95.72 13265.0 296520.0 0.200362 1811.084839 2021-01-01
1 2020-01-01 1.622880e-07 3548930.5 254.962936 296120.0625 75499640.0 10912.768301 6.836727 0.180845 1.622880e-07 242118.0 [[296495.0, 14.0, 6.0, 2.0, 1.0, 0.0, 0.0, 1.0... 95.72 13265.0 296520.0 0.182224 1713.106445 2020-01-01
2 2019-01-01 1.877873e-07 3369803.0 276.884796 296120.0625 81991144.0 11799.911186 7.814598 0.527155 1.877873e-07 242967.0 [[296495.0, 13.0, 6.0, 3.0, 0.0, 0.0, 0.0, 1.0... 95.72 13265.0 296520.0 0.212244 1882.463623 2019-01-01
3 2018-01-01 1.853067e-07 3868559.5 278.522980 296120.0625 82476240.0 12222.416782 7.711860 0.519930 1.853067e-07 242928.0 [[296497.0, 14.0, 6.0, 0.0, 0.0, 0.0, 1.0, 0.0... 95.72 13265.0 296520.0 0.208977 1912.632568 2018-01-01
4 2017-01-01 1.802980e-07 4050962.5 271.169403 296120.0625 80298704.0 13290.472377 7.446557 0.505795 1.802980e-07 242922.0 [[296499.0, 14.0, 3.0, 0.0, 0.0, 1.0, 1.0, 0.0... 95.72 13265.0 296520.0 0.203270 1775.784790 2017-01-01

Visualizing the Data as a Time Series

We can now explore the total fossil fuel emission time series (2010 -2021) available for the Dallas, Texas area of the U.S. We can plot the data set using the code below:

# Figure size: 20 representing the width, 10 representing the height
fig = plt.figure(figsize=(20, 10))

plt.plot(
    df["datetime"], # X-axis: sorted datetime
    df["max"], # Y-axis: maximum CO₂
    color="red", # Line color
    linestyle="-", # Line style
    linewidth=0.5, # Line width
    label="CO₂ emissions", # Legend label
)

# Display legend
plt.legend()

# Insert label for the X-axis
plt.xlabel("Years")

# Insert label for the Y-axis
plt.ylabel("tC/km²/year")
plt.xticks(rotation = 90)

# Insert title for the plot
plt.title("Total Fossil Fuel CO₂ Emissions for Texas, Dallas (2010-2021)")

# Add data citation
plt.text(
    df["datetime"].iloc[0],           # X-coordinate of the text
    df["max"].min(),                  # Y-coordinate of the text




    # Text to be displayed
    "Source: https://doi.org/10.3334/ORNLDAAC/1741",                  
    fontsize=12,                             # Font size
    horizontalalignment="left",              # Horizontal alignment
    verticalalignment="top",                 # Vertical alignment
    color="blue",                            # Text color
)


# Plot the time series
plt.show()

Summary

In this notebook we have successfully explored, analyzed, and visualized the STAC collection for Vulcan Fossil Fuel CO₂ Emissions, Version 4 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 total fossil fuel CO₂ emissions for two distinctive months/years
  5. Generate zonal statistics for the area of interest (AOI)
  6. Visualizing the Data as a Time Series

If you have any questions regarding this user notebook, please contact us using the feedback form.

Back to top