Once the appropriate Conda environment has been configured and selected or required packages manually installed in a SageMaker Studio notebook instance, the Python libraries can be directly imported to enable development. The integration of Conda and pip with SageMaker Studio notebooks allows for reproducible, sharable software environments tailored to a project's needs, consistent with research computing best practices. By proactively managing the notebook environment early in development, dependencies can be established to facilitate smoother workflow execution, analysis, collaboration, and review. Overall, conscious creation of computing environments removes technical barriers and enables fuller focus on the research questions at hand within SageMaker Studio.
import pandas as pd
import numpy as np
import geopandas as gpd
from shapely.geometry import Point
import matplotlib
import matplotlib.pyplot as plt
import os
import warnings
import datetime
import json
import boto3
import gc
import rasterio as rio
import os
import earthpy.spatial as es
import earthpy.plot as ep
import imageio
import io
import awswrangler as wr
import json
%matplotlib inline
warnings.filterwarnings('ignore')
Step 3: Working With Geospatial Images
For geospatial analysis, Sentinel-2 satellite imagery will be utilized as the remote sensing dataset given its public availability through the AWS open data registry. The Sentinel-2 constellation provides ongoing high-resolution multispectral coverage as the continuation of prior SPOT and Landsat Earth observation programs. The sentinelhub Python package facilitates straightforward search and access to Sentinel-2 scenes relevant to the area of interest from the registry. Incorporation of Sentinel-2 facilitates time-series analysis of landscape dynamics pertinent to sustainability topics. The AWSD registry lowers barriers to leveraging Sentinel-2 and similar public domain remotely sensed data.
from sentinelhub import (
MimeType,
CRS,
BBox,
SentinelHubRequest,
SentinelHubDownloadClient,
DataCollection,
bbox_to_dimensions,
DownloadRequest
)
3. 1 - Sentinel Hub Setup
Proper configuration of access credentials is required to utilize the Sentinel Hub API for retrieval of remotely sensed data. An optional JSON file stores the authentication parameters to enable programmatic queries while keeping sensitive tokens secure. Specifically, a valid
Sentinel Hub instance ID is necessary and suffices for read-only data access. Abstracting the credentials into a separate file facilitates sharing of analysis code without compromising security. More broadly, use of APIs and environmental variables for handling credentials promotes reproducibility and collaboration by avoiding hard-coding of tokens within software projects. With credentials configured appropriately, the analysis can then focus solely on core research questions without impedance from security control permissions.
from sentinelhub import SHConfig
config = SHConfig()
# instance_id - Instance ID from from your Sentinel Hub account
config.instance_id = 'please update with your instance id'
config.save()
# Verify credentials
from sentinelhub import WebFeatureService, BBox, CRS, DataCollection, SHConfig
if config.instance_id == '':
print("Warning! To use WFS functionality, please configure the 'instance_id'.")
3.2 - Data Search
Defining the spatiotemporal domain is an essential initial step for targeted retrieval of remotely sensed data. Our area of interest centers on Paradise, CA, impacted by recent wildfires. We specify geospatial boundaries via a bounding box encompassing Paradise and select a time range spanning pre- and post-fire landscapes. Explicitly delineating the target geographic extent and time window provides precise criteria for the API to identify and retrieve relevant Sentinel satellite observations. Tailored queries focusing on the research aims help filter and collect imagery capturing landscape change dynamics within the region of study. Careful query formulation reduces data volumes for storage and analysis while isolating observations most likely to inform about fire ecology in Paradise. Explicit articulation of retrieval parameters promotes reproducibility and interpretability as well when sharing or publishing analytical findings.
# Specify bounding box and time interval for search
#california paradise after fire
search_bbox = BBox(bbox=[-121.666536,39.708771,-121.542266,39.792182],crs=CRS.WGS84)
#before fire
#search_time_interval = ('2018-11-01T00:00:00', '2018-11-01T23:59:59')
#after fire
search_time_interval = ('2019-01-10T00:00:00', '2019-01-10T23:59:59')
wfs_iterator = WebFeatureService(
search_bbox,
search_time_interval,
data_collection=DataCollection.SENTINEL2_L1C,
maxcc=0.6,
config=config
)
for tile_info in wfs_iterator:
print(tile_info)
##before fire bucket - s3://sentinel-s2-l1c/tiles/10/T/FK/2018/11/1/0
##after fire bucket - s3://sentinel-s2-l1c/tiles/10/T/FK/2019/1/10/0
3.3 - Working With Geospatial Images
For geospatial analysis in this research, Sentinel-2 satellite imagery is utilized given its public availability through the AWS open data registry. The Sentinel-2 constellation offers ongoing high-resolution multispectral Earth observations across 13 bands spanning the visible, near infrared, and shortwave infrared wavelengths. This continues prior Landsat and SPOT programs' systematic collection of optical remote sensing data useful for environmental monitoring. Specifically, each Sentinel-2 satellite carries a MultiSpectral Instrument sensor designed to capture spectral reflectance signatures of ground surface materials across the specified bands at 10-60 meter pixel resolution. Further technical specifics on the instrument band designations and purposes are available in the accompanying references. When analyzed sequentially or in combination, these spectra facilitate study of landscape dynamics like vegetation growth, burn recovery, and other phenomena pertinent to ecological sustainability challenges. Incorporation of open access Sentinel-2 data thereby enables timely investigation of research questions relying on Earth observation resources.
The Sentinel-2 satellites each carry a single multi-spectral instrument (MSI) with 13 spectral channels in the visible/near infrared (VNIR) and short wave infrared spectral range (SWIR). You can read more about these bands
here.