import re
import pandas as pd
import json
import tempfile
import boto3
EMIT Methane Point Source Plume Complexes
Documentation of data transformation
This script was used to read the EMIT Methane Point Source Plume Complexes dataset provided in Cloud Optimized GeoTIFF (COG) format for display in the Greenhouse Gas (GHG) Center.
= boto3.session.Session(profile_name="ghg_user")
session_ghgc = session_ghgc.client("s3")
s3_client_ghgc = boto3.session.Session()
session_veda_smce = session_veda_smce.client("s3")
s3_client_veda_smce
# Since the plume emissions were already COGs, we just had to transform their naming convention to be stored in the STAC collection.
= "ghgc-data-staging-uah"
SOURCE_BUCKET_NAME = "ghgc-data-store-dev"
TARGET_BUCKET_NAME
= []
keys = s3_client_ghgc.list_objects_v2(Bucket=SOURCE_BUCKET_NAME)
resp for obj in resp["Contents"]:
if "l3" in obj["Key"]:
"Key"])
keys.append(obj[
for key in keys:
= s3_client_ghgc.get_object(Bucket=SOURCE_BUCKET_NAME, Key=key)[
s3_obj "Body"
]= key.split("/")[-1]
filename = re.split("[_ .]", filename)
filename_elements
= re.search("t\d\d\d\d\d\d\d\dt", key).group(0)
date -1, date[1:-1])
filename_elements.insert(
filename_elements.pop()
= "_".join(filename_elements)
cog_filename # # add extension
= f"{cog_filename}.tif"
cog_filename
s3_client_veda_smce.upload_fileobj(=s3_obj,
Fileobj=TARGET_BUCKET_NAME,
Bucket=f"plum_data/{cog_filename}",
Key )