{ "cells": [ { "cell_type": "markdown", "id": "bd2c40c2", "metadata": {}, "source": [ "# Getting Started with OPERA DIST-ALERT-HLS Products" ] }, { "cell_type": "markdown", "id": "50582538", "metadata": {}, "source": [ "## Streaming and visualizing Cloud-Optimized GeoTIFF (COG) OPERA DIST-ALERT-HLS products using CMR's SpatioTemporal Asset Catalog (CMR-STAC)" ] }, { "cell_type": "markdown", "id": "1183b136", "metadata": {}, "source": [ "### This tutorial demonstrates how to query and work with the OPERA DIST-ALERT-HLS Provisional Data products from the cloud ([OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0](https://lpdaac.usgs.gov/products/opera_l3_dist-alert-hls_provisional_v0v000/)).\n", "---" ] }, { "cell_type": "markdown", "id": "06f3add4", "metadata": {}, "source": [ "### Data Used in the Example" ] }, { "cell_type": "markdown", "id": "e79a3966", "metadata": {}, "source": [ "* **30 meter (m) global OPERA Land Surface Disturbance Alert from Harmonized Landsat Sentinel-2 provisional product (Version 0) - [OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0](https://lpdaac.usgs.gov/products/opera_l3_dist-alert-hls_provisional_v0v000/)**
\n", " - The Observational Products for End-Users from Remote Sensing Analysis (OPERA) Land Surface Disturbance Alert from Harmonized Landsat Sentinel-2 (HLS) provisional data product Version 0 maps vegetation disturbance alerts from data collected by Landsat 8 and Landsat 9 Operational Land Imager (OLI) and Sentinel-2A and Sentinel-2B Multi-Spectral Instrument (MSI). Vegetation disturbance alert is detected at 30 meter (m) spatial resolution when there is an indicated decrease in vegetation cover within an HLS pixel. The product also provides auxiliary generic disturbance information as determined from the variations of the reflectance through the HLS scenes to provide information about more general disturbance trends. HLS data represent the highest temporal frequency data available at medium spatial resolution. The combined observations will provide greater sensitivity to land changes, whether of large magnitude/short duration, or small magnitude/long duration.\n", " - The OPERA_L3_DIST-ALERT-HLS (or DIST-ALERT) data product is provided in Cloud Optimized GeoTIFF (COG) format, and each layer is distributed as a separate file. There are 19 layers contained within in the DIST-ALERT product: vegetation disturbance status, current vegetation cover indicator, current vegetation anomaly value, historical vegetation cover indicator, max vegetation anomaly value, vegetation disturbance confidence layer, date of initial vegetation disturbance, number of detected vegetation loss anomalies, and vegetation disturbance duration. See the Product Specification for a more detailed description of the individual layers provided in the DIST-ALERT product.\n", "* **Science Dataset (SDS) Layers**\n", " - VEG_ANOM_MAX (Maximum Vegetation Anomaly Layer)\n", " - VEG_DIST_DATE (Vegetation Disturbance Date Layer)\n", " - VEG_DIST_STATUS (Vegetation Disturbance Status Layer)" ] }, { "cell_type": "markdown", "id": "0cddfc9c", "metadata": {}, "source": [ "Please refer to the [OPERA DIST Product Specification Document](https://d2pn8kiwq2w21t.cloudfront.net/documents/ProductSpec_DIST_HLS.pdf) for details about the DIST-ALERT-HLS product.\n", "

\n", "\n", "---\n", "
\n", "\n", "## Topics Covered\n", "> 1. Getting Started\n", "> 2. CMR-STAC API: Search for data based on spatial query\n", "> 3. Load and visualize DIST-ALERT-HLS COGs from the Cloud\n", "> 4. Demonstrate time slider visualization tool\n", "
\n", "---\n", "
\n", "\n", "## Before Starting this Tutorial\n", "A [NASA Earthdata Login](https://urs.earthdata.nasa.gov) account is required to download the data used in this tutorial. You can create an account using the link provided.\n", "

\n", "---\n" ] }, { "cell_type": "markdown", "id": "0ba52a33", "metadata": {}, "source": [ "## 1. Getting Started
\n", "### 1.1 Import Packages" ] }, { "cell_type": "code", "execution_count": 1, "id": "fbcf2d5f", "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 2, "id": "acb3a07a", "metadata": {}, "outputs": [], "source": [ "# Notebook dependencies\n", "import os\n", "from netrc import netrc\n", "from subprocess import Popen\n", "from platform import system\n", "from getpass import getpass\n", "\n", "from pystac_client import Client \n", "from pystac_client import ItemSearch\n", "from pystac.item import Item\n", "from typing import Dict, Any\n", "import json\n", "\n", "import matplotlib.pyplot as plt\n", "from matplotlib import cm\n", "import matplotlib as mpl\n", "from matplotlib.colors import ListedColormap\n", "from datetime import datetime, timedelta\n", "from tqdm import tqdm\n", "import math\n", "\n", "from shapely.geometry import box\n", "from shapely.geometry import shape\n", "from shapely.ops import transform\n", "\n", "import numpy as np\n", "import numpy.ma as ma\n", "import pandas as pd\n", "import geopandas as gpd\n", "from skimage import io\n", "\n", "from osgeo import gdal\n", "import rasterio as rio\n", "import rioxarray\n", "from rioxarray.merge import merge_arrays\n", "\n", "import folium\n", "from folium import plugins\n", "\n", "import pyproj\n", "from pyproj import Proj\n", "\n", "import xarray as xr\n", "import panel as pn\n", "import panel.widgets as pnw\n", "import geoviews as gv\n", "import hvplot.xarray\n", "import holoviews as hv\n", "\n", "from bokeh.models import FixedTicker\n", "hv.extension('bokeh')\n", "gv.extension('bokeh', 'matplotlib')\n", "\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "from Stream_and_Viz_DIST_Functions import intersection_percent, stack_bands, time_and_area_cube, compute_area, standard_date, colorize, mask_rasters, getbasemaps, transform_data_for_folium\n" ] }, { "cell_type": "markdown", "id": "58fd0cdd", "metadata": {}, "source": [ "### 1.2 Set Up Working Environment" ] }, { "cell_type": "code", "execution_count": 3, "id": "893433ec", "metadata": {}, "outputs": [], "source": [ "inDir = os.getcwd()\n", "os.chdir(inDir)" ] }, { "cell_type": "markdown", "id": "e4cb82db", "metadata": {}, "source": [ "### 1.3 Generate Authentication Token\n", "\n", "The cell below generates an authentication token and asks for your Earthdata username/password the first time if netrc does not exist in your home directory." ] }, { "cell_type": "code", "execution_count": 4, "id": "332dddf9", "metadata": {}, "outputs": [], "source": [ "urs = 'urs.earthdata.nasa.gov' # Earthdata URL endpoint for authentication\n", "prompts = ['Enter NASA Earthdata Login Username: ',\n", " 'Enter NASA Earthdata Login Password: ']\n", "\n", "# Determine the OS (Windows machines usually use an '_netrc' file)\n", "netrc_name = \"_netrc\" if system()==\"Windows\" else \".netrc\"\n", "\n", "# Determine if netrc file exists, and if so, if it includes NASA Earthdata Login Credentials\n", "try:\n", " netrcDir = os.path.expanduser(f\"~/{netrc_name}\")\n", " netrc(netrcDir).authenticators(urs)[0]\n", "\n", "# Below, create a netrc file and prompt user for NASA Earthdata Login Username and Password\n", "except FileNotFoundError:\n", " homeDir = os.path.expanduser(\"~\")\n", " Popen('touch {0}{2} | echo machine {1} >> {0}{2}'.format(homeDir + os.sep, urs, netrc_name), shell=True)\n", " Popen('echo login {} >> {}{}'.format(getpass(prompt=prompts[0]), homeDir + os.sep, netrc_name), shell=True)\n", " Popen('echo \\'password {} \\'>> {}{}'.format(getpass(prompt=prompts[1]), homeDir + os.sep, netrc_name), shell=True)\n", " # Set restrictive permissions\n", " Popen('chmod 0600 {0}{1}'.format(homeDir + os.sep, netrc_name), shell=True)\n", "\n", "# Determine OS and edit netrc file if it exists but is not set up for NASA Earthdata Login\n", "except TypeError:\n", " homeDir = os.path.expanduser(\"~\")\n", " Popen('echo machine {1} >> {0}{2}'.format(homeDir + os.sep, urs, netrc_name), shell=True)\n", " Popen('echo login {} >> {}{}'.format(getpass(prompt=prompts[0]), homeDir + os.sep, netrc_name), shell=True)\n", " Popen('echo \\'password {} \\'>> {}{}'.format(getpass(prompt=prompts[1]), homeDir + os.sep, netrc_name), shell=True)" ] }, { "cell_type": "code", "execution_count": 5, "id": "629fb602", "metadata": {}, "outputs": [], "source": [ "# GDAL configurations used to successfully access PODAAC Cloud Assets via vsicurl \n", "gdal.SetConfigOption('GDAL_HTTP_COOKIEFILE','~/cookies.txt')\n", "gdal.SetConfigOption('GDAL_HTTP_COOKIEJAR', '~/cookies.txt')\n", "gdal.SetConfigOption('GDAL_DISABLE_READDIR_ON_OPEN','EMPTY_DIR')\n", "gdal.SetConfigOption('CPL_VSIL_CURL_ALLOWED_EXTENSIONS','TIF, TIFF')" ] }, { "cell_type": "markdown", "id": "62e6c94d", "metadata": {}, "source": [ "## 2. CMR_STAC API: Search for Data Based on Spatial Query and Cloud Cover" ] }, { "cell_type": "markdown", "id": "2fe59cb9", "metadata": {}, "source": [ "### 2.1 Initialize User-Defined Parameters\n", "\n", "The user should only specify parameters in the cell directly below, indicating:\n", "* **Area of Interest**: coordinates entered as a shapely.geometry box object\n", "* **Start and Stop Dates of Interest**: default stop date is set as present day\n", "* **Overlap Threshold**: minimum required % spatial overlap between the AOI and DIST tiles obtained through search for DIST tile to be deemed \"acceptable\"\n", "* **Cloud Cover Threshold**: maximum % cloud cover allowed for a DIST tile to be deemed \"acceptable\"\n" ] }, { "cell_type": "code", "execution_count": 6, "id": "7e0f5819", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Search between 2022-01-01 00:00:00 and 2023-05-16 23:59:59\n", "With AOI: {'type': 'Polygon', 'coordinates': (((-104.8928408, 35.1544515), (-104.8928408, 36.1448493), (-105.3259771, 36.1448493), (-105.3259771, 35.1544515), (-104.8928408, 35.1544515)),)}\n" ] } ], "source": [ "# User-Defined Parameters\n", "# aoi = box(67.991, 27.051, 68.002, 27.089)\n", "aoi = box(-105.3259771, 35.1544515,-104.8928408, 36.1448493)\n", "start_date = datetime(2022, 1, 1) \n", "stop_date = f\"{datetime.today().strftime('%Y-%m-%d')} 23:59:59\" \n", "overlap_threshold = 50 \n", "cloud_cover_threshold = 20 \n", "\n", "print(f\"Search between {start_date} and {stop_date}\")\n", "print(f\"With AOI: {aoi.__geo_interface__}\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "01dc8258", "metadata": {}, "outputs": [], "source": [ "# Search data through CMR-STAC API\n", "stac = 'https://cmr.earthdata.nasa.gov/cloudstac/' # CMR-STAC API Endpoint\n", "api = Client.open(f'{stac}/LPCLOUD/')\n", "collections = ['OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0']\n", "\n", "search_params = {\"collections\": collections,\n", " \"intersects\": aoi.__geo_interface__,\n", " \"datetime\": [start_date, stop_date],\n", " \"limit\": 50,\n", " \"max_items\": 1000\n", " }\n", "search_dist = api.search(**search_params)" ] }, { "cell_type": "markdown", "id": "7ad175ed", "metadata": {}, "source": [ "### 2.2 Query DIST-ALERT-HLS tiles based on cloud cover and spatial overlap with respect to defined AOI" ] }, { "cell_type": "code", "execution_count": 8, "id": "3fd16ebe", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Percent overlap before filtering: \n", "['2.21', '68.61', '3.54', '24.78', '8.68', '2.21', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '99.90', '24.78', '8.85', '2.22', '2.21', '3.25', '65.15', '24.78', '8.36', '2.21', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '8.99', '2.21', '99.90', '8.85', '24.78', '2.22', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '24.78', '68.36', '3.52', '8.66', '2.21', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '24.78', '2.22', '8.85', '99.90', '2.21', '24.78', '3.30', '65.76', '8.43', '2.21', '2.21', '8.99', '2.21', '8.95', '38.77', '8.85', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '8.85', '2.22', '24.78', '99.90', '2.21', '3.20', '24.78', '64.69', '8.32', '2.21', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '8.99', '2.21', '24.78', '2.22', '8.85', '99.90', '2.21', '24.78', '63.37', '3.10', '8.22', '2.21', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '99.90', '24.78', '2.22', '8.85', '2.21', '67.27', '3.42', '24.78', '2.21', '8.56', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '2.22', '8.85', '24.78', '99.90', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '24.78', '69.03', '3.58', '2.21', '8.71', '2.21', '8.99', '24.78', '99.90', '8.85', '8.99', '2.21', '2.22', '8.85', '24.78', '99.90', '2.21', '3.42', '24.78', '67.12', '2.21', '8.55', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '2.21', '8.99', '24.78', '99.90', '2.21', '8.85', '8.99', '2.21', '2.22', '8.85', '99.90', '24.78', '2.21', '24.78', '3.66', '69.94', '2.21', '8.77']\n", "\n", "Percent cloud cover before filtering: \n", "['15', '3', '23', '1', '0', '0', '0', '8', '0', '6', '0', '1', '73', '40', '22', '43', '0', '4', '29', '32', '50', '23', '30', '3', '40', '29', '48', '71', '100', '100', '100', '54', '82', '70', '83', '43', '7', '1', '3', '1', '0', '0', '1', '4', '0', '4', '0', '1', '100', '81', '81', '100', '37', '37', '4', '30', '14', '44', '46', '51', '25', '88', '50', '10', '38', '86', '84', '65', '100', '47', '57', '90', '73', '80', '30', '17', '57', '65', '57', '5', '12', '3', '0', '1', '0', '42', '2', '0', '0', '5', '15', '75', '11', '5', '2', '1', '0', '1', '0', '1', '0', '7', '54', '38', '2', '53', '47', '7', '15', '3', '10', '45', '8', '3', '25', '70', '3', '61', '1', '59', '99', '71', '96', '99', '100', '100', '5', '21', '10', '1', '0', '3', '2', '1', '3', '0', '0', '0', '36', '9', '0', '4', '0', '3', '2', '19', '2', '37', '9', '27', '2', '22', '12', '16', '26', '16', '88', '80', '51', '93', '92', '58', '93', '60', '100', '89', '96', '45', '18', '17', '78', '22', '45', '78', '99', '90', '100', '98', '84', '26', '48', '34', '29', '8', '30', '2', '12', '0', '1', '0', '2', '11', '0', '0', '0', '4', '0', '2', '1', '19', '0', '0', '0']\n" ] } ], "source": [ "# Filter datasets based on spatial overlap and cloud cover\n", "intersects_geometry = aoi.__geo_interface__\n", "\n", "#Check percent overlap values\n", "print(\"Percent overlap before filtering: \")\n", "print([f\"{intersection_percent(i, intersects_geometry):.2f}\" for i in search_dist.items()])\n", "\n", "# Check percent cloud cover values\n", "print(\"\\nPercent cloud cover before filtering: \")\n", "print([f\"{i.properties['eo:cloud_cover']}\" for i in search_dist.items()])" ] }, { "cell_type": "markdown", "id": "a1c06d3d", "metadata": {}, "source": [ "The percent spatial overlap values above vary from only 40% to a perfect 100%. The following filtering process will only keep tiles with spatial overlap greater than 50%. Similarly, cloud cover values ranging from 0 to 100 can be observed above. The filtering process will also only keep tiles with less than 20% cloud cover." ] }, { "cell_type": "code", "execution_count": 9, "id": "9fc21ba0", "metadata": {}, "outputs": [], "source": [ "# Apply spatial overlap and cloud cover threshold\n", "dist_filtered = (\n", " i for i in search_dist.items() if (intersection_percent(i, intersects_geometry) \n", " > overlap_threshold and \n", " i.properties['eo:cloud_cover'] < cloud_cover_threshold)\n", ")" ] }, { "cell_type": "markdown", "id": "0871743a", "metadata": {}, "source": [ "Inspecting one DIST tile from the filtered query, its metadata can be easily accessed as seen below." ] }, { "cell_type": "code", "execution_count": 10, "id": "40788331", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'type': 'Feature',\n", " 'stac_version': '1.0.0',\n", " 'id': 'OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0',\n", " 'properties': {'eo:cloud_cover': 3,\n", " 'datetime': '2023-02-27T17:32:34.868000Z',\n", " 'start_datetime': '2023-02-27T17:32:34.868Z',\n", " 'end_datetime': '2023-02-27T17:32:58.751Z'},\n", " 'geometry': {'type': 'Polygon',\n", " 'coordinates': [[[-105.3259771, 35.1544515],\n", " [-104.8928408, 35.1548427],\n", " [-104.8915104, 36.1448493],\n", " [-105.0542448, 36.1448861],\n", " [-105.3259771, 35.1544515]]]},\n", " 'links': [{'rel': 'self',\n", " 'href': 'https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD/collections/OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0.v0/items/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0'},\n", " {'rel': 'parent',\n", " 'href': 'https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD/collections/OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0.v0'},\n", " {'rel': 'collection',\n", " 'href': 'https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD/collections/OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0.v0'},\n", " {'rel': ,\n", " 'href': 'https://cmr.earthdata.nasa.gov/cloudstac//LPCLOUD/',\n", " 'type': ,\n", " 'title': 'LPCLOUD'},\n", " {'rel': 'provider',\n", " 'href': 'https://cmr.earthdata.nasa.gov/cloudstac/LPCLOUD'},\n", " {'rel': 'via',\n", " 'href': 'https://cmr.earthdata.nasa.gov/search/concepts/G2623670033-LPCLOUD.json'},\n", " {'rel': 'via',\n", " 'href': 'https://cmr.earthdata.nasa.gov/search/concepts/G2623670033-LPCLOUD.umm_json'}],\n", " 'assets': {'000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS_browse': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS_browse.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS_browse.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-IND': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-IND.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-IND.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-HIST': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-HIST.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-HIST.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM-MAX': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM-MAX.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-ANOM-MAX.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-CONF': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-CONF.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-CONF.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DATE': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DATE.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DATE.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-COUNT': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-COUNT.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-COUNT.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DUR': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DUR.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-DUR.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-LAST-DATE': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-LAST-DATE.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-LAST-DATE.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-STATUS': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-STATUS.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-STATUS.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM-MAX': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM-MAX.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-ANOM-MAX.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-CONF': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-CONF.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-CONF.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DATE': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DATE.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DATE.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-COUNT': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-COUNT.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-COUNT.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DUR': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DUR.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-DIST-DUR.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-LAST-DATE': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-LAST-DATE.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_GEN-LAST-DATE.tif'},\n", " '000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_LAND-MASK': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-protected/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_LAND-MASK.tif',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_LAND-MASK.tif'},\n", " 'browse': {'href': 'https://data.lpdaac.earthdatacloud.nasa.gov/lp-prod-public/OPERA_L3_DIST-ALERT-HLS_PROV.000/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0/OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS.png',\n", " 'type': 'image/png',\n", " 'title': 'Download OPERA_L3_DIST-ALERT-HLS_T13SDV_20230227T173234Z_20230301T133825Z_L9_30_v0_VEG-DIST-STATUS.png'},\n", " 'metadata': {'href': 'https://cmr.earthdata.nasa.gov/search/concepts/G2623670033-LPCLOUD.xml',\n", " 'type': 'application/xml'}},\n", " 'bbox': [-105.325977, 35.154452, -104.89151, 36.144898],\n", " 'stac_extensions': ['https://stac-extensions.github.io/eo/v1.0.0/schema.json'],\n", " 'collection': 'OPERA_L3_DIST-ALERT-HLS_PROVISIONAL_V0.v0'}" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dist_data = list(dist_filtered)\n", "\n", "dist_data[0].to_dict()" ] }, { "cell_type": "code", "execution_count": 11, "id": "983354e3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Total granules after search filter: 17\n", "Percent-overlap: \n", "['68.61', '99.90', '99.90', '99.90', '99.90', '99.90', '64.69', '99.90', '99.90', '63.37', '99.90', '67.27', '99.90', '99.90', '99.90', '99.90', '69.94']\n", "Cloud-cover: \n", "['3', '6', '3', '4', '3', '5', '5', '1', '7', '10', '10', '1', '4', '16', '1', '4', '0']\n" ] } ], "source": [ "# Print search information\n", "# Total granules\n", "print(f\"Total granules after search filter: {len(dist_data)}\")\n", "\n", "# Check percent overlap values\n", "print(\"Percent-overlap: \")\n", "print([f\"{intersection_percent(i, intersects_geometry):.2f}\" for i in dist_data])\n", "\n", "# Check cloud cover values\n", "print(\"Cloud-cover: \")\n", "print([f\"{x.properties['eo:cloud_cover']}\" for x in dist_data])" ] }, { "cell_type": "markdown", "id": "6a6d7d9f", "metadata": {}, "source": [ "Observing percent spatial overlap and cloud cover values after filtering, it is evident that only DIST tiles covering most of the AOI with minimal cloud cover are now available to the user.

In the figure produced below, the overlap between the boundary of the AOI and varying DIST tile boundaries is shown over a basemap." ] }, { "cell_type": "code", "execution_count": 12, "id": "6ffd37e8", "metadata": { "scrolled": false }, "outputs": [ { "data": {}, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.holoviews_exec.v0+json": "", "text/html": [ "
\n", "
\n", "
\n", "" ], "text/plain": [ ":Overlay\n", " .Polygons.I :Polygons [Longitude,Latitude]\n", " .WMTS.I :WMTS [Longitude,Latitude]\n", " .Polygons.II :Polygons [Longitude,Latitude]" ] }, "execution_count": 12, "metadata": { "application/vnd.holoviews_exec.v0+json": { "id": "1004" } }, "output_type": "execute_result" } ], "source": [ "# Visualize the DIST tile boundary and the user-defined box\n", "geom_df = []\n", "for d,_ in enumerate(dist_data):\n", " geom_df.append(shape(dist_data[d].geometry))\n", "\n", "geom_granules = gpd.GeoDataFrame({'geometry':geom_df})\n", "granules_poly = gv.Polygons(geom_granules).opts(line_color='blue', color=None)\n", "\n", "# Use geoviews to combine a basemap with the shapely polygon of our Region of Interest (ROI)\n", "base = gv.tile_sources.EsriImagery.opts(width=1000, height=1000)\n", "\n", "# Get the user-specified aoi\n", "geom_aoi = shape(intersects_geometry)\n", "aoi_poly = gv.Polygons(geom_aoi).opts(line_color='yellow', color=None)\n", "\n", "# Plot using geoviews wrapper\n", "granules_poly*base*aoi_poly" ] }, { "cell_type": "markdown", "id": "ab9a0a5c", "metadata": {}, "source": [ "DIST tiles adhering to the spatial overlap and cloud cover thresholds can be sorted in the table below, listing each tile's spatial coverage, cloud cover, and bandlink." ] }, { "cell_type": "code", "execution_count": 13, "id": "49e1a027", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
TileIDSensorDateCoordsbboxSpatialCoverageCloudCoverBandLinks
0T13SDVL92023-02-27{'type': 'Polygon', 'coordinates': [[[-105.325...[-105.325977, 35.154452, -104.89151, 36.144898]68.6134263[https://data.lpdaac.earthdatacloud.nasa.gov/l...
1T13SDVS2A2023-02-27{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034696[https://data.lpdaac.earthdatacloud.nasa.gov/l...
2T13SDVL82023-03-14{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034693[https://data.lpdaac.earthdatacloud.nasa.gov/l...
3T13SDVS2B2023-03-14{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034694[https://data.lpdaac.earthdatacloud.nasa.gov/l...
4T13SDVS2A2023-03-29{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034693[https://data.lpdaac.earthdatacloud.nasa.gov/l...
5T13SDVL82023-03-30{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034695[https://data.lpdaac.earthdatacloud.nasa.gov/l...
6T13SDVL92023-03-31{'type': 'Polygon', 'coordinates': [[[-105.308...[-105.30885, 35.154496, -104.89151, 36.144849]64.6861395[https://data.lpdaac.earthdatacloud.nasa.gov/l...
7T13SDVS2B2023-04-03{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034691[https://data.lpdaac.earthdatacloud.nasa.gov/l...
8T13SDVL92023-04-07{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034697[https://data.lpdaac.earthdatacloud.nasa.gov/l...
9T13SDVL82023-04-08{'type': 'Polygon', 'coordinates': [[[-105.303...[-105.30325, 35.154511, -104.89151, 36.144898]63.37256510[https://data.lpdaac.earthdatacloud.nasa.gov/l...
10T13SDVL82023-04-15{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.90346910[https://data.lpdaac.earthdatacloud.nasa.gov/l...
11T13SDVL92023-04-16{'type': 'Polygon', 'coordinates': [[[-105.320...[-105.320048, 35.154467, -104.89151, 36.144898]67.2746711[https://data.lpdaac.earthdatacloud.nasa.gov/l...
12T13SDVS2A2023-04-18{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034694[https://data.lpdaac.earthdatacloud.nasa.gov/l...
13T13SDVS2B2023-04-23{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.90346916[https://data.lpdaac.earthdatacloud.nasa.gov/l...
14T13SDVS2A2023-05-08{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034691[https://data.lpdaac.earthdatacloud.nasa.gov/l...
15T13SDVL92023-05-09{'type': 'Polygon', 'coordinates': [[[-106.098...[-106.111925, 35.149912, -104.89151, 36.144896]99.9034694[https://data.lpdaac.earthdatacloud.nasa.gov/l...
16T13SDVL82023-05-10{'type': 'Polygon', 'coordinates': [[[-105.331...[-105.331577, 35.154436, -104.89151, 36.144898]69.9393180[https://data.lpdaac.earthdatacloud.nasa.gov/l...
\n", "
" ], "text/plain": [ " TileID Sensor Date \\\n", "0 T13SDV L9 2023-02-27 \n", "1 T13SDV S2A 2023-02-27 \n", "2 T13SDV L8 2023-03-14 \n", "3 T13SDV S2B 2023-03-14 \n", "4 T13SDV S2A 2023-03-29 \n", "5 T13SDV L8 2023-03-30 \n", "6 T13SDV L9 2023-03-31 \n", "7 T13SDV S2B 2023-04-03 \n", "8 T13SDV L9 2023-04-07 \n", "9 T13SDV L8 2023-04-08 \n", "10 T13SDV L8 2023-04-15 \n", "11 T13SDV L9 2023-04-16 \n", "12 T13SDV S2A 2023-04-18 \n", "13 T13SDV S2B 2023-04-23 \n", "14 T13SDV S2A 2023-05-08 \n", "15 T13SDV L9 2023-05-09 \n", "16 T13SDV L8 2023-05-10 \n", "\n", " Coords \\\n", "0 {'type': 'Polygon', 'coordinates': [[[-105.325... \n", "1 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "2 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "3 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "4 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "5 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "6 {'type': 'Polygon', 'coordinates': [[[-105.308... \n", "7 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "8 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "9 {'type': 'Polygon', 'coordinates': [[[-105.303... \n", "10 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "11 {'type': 'Polygon', 'coordinates': [[[-105.320... \n", "12 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "13 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "14 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "15 {'type': 'Polygon', 'coordinates': [[[-106.098... \n", "16 {'type': 'Polygon', 'coordinates': [[[-105.331... \n", "\n", " bbox SpatialCoverage \\\n", "0 [-105.325977, 35.154452, -104.89151, 36.144898] 68.613426 \n", "1 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "2 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "3 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "4 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "5 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "6 [-105.30885, 35.154496, -104.89151, 36.144849] 64.686139 \n", "7 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "8 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "9 [-105.30325, 35.154511, -104.89151, 36.144898] 63.372565 \n", "10 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "11 [-105.320048, 35.154467, -104.89151, 36.144898] 67.274671 \n", "12 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "13 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "14 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "15 [-106.111925, 35.149912, -104.89151, 36.144896] 99.903469 \n", "16 [-105.331577, 35.154436, -104.89151, 36.144898] 69.939318 \n", "\n", " CloudCover BandLinks \n", "0 3 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "1 6 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "2 3 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "3 4 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "4 3 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "5 5 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "6 5 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "7 1 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "8 7 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "9 10 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "10 10 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "11 1 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "12 4 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "13 16 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "14 1 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "15 4 [https://data.lpdaac.earthdatacloud.nasa.gov/l... \n", "16 0 [https://data.lpdaac.earthdatacloud.nasa.gov/l... " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Create table of search results\n", "dist_data_df = []\n", "for item in dist_data:\n", " item.to_dict()\n", " fn = item.id.split('_')\n", " ID = fn[3]\n", " sensor = fn[6]\n", " dat = item.datetime.strftime('%Y-%m-%d')\n", " spatial_coverage = intersection_percent(item, intersects_geometry)\n", " cloud_cover = item.properties['eo:cloud_cover']\n", " geom = item.geometry\n", " bbox = item.bbox\n", "\n", " # Take all the band href information \n", " band_links = [item.assets[links].href for links in item.assets.keys()]\n", " dist_data_df.append([ID,sensor,dat,geom,bbox,spatial_coverage,cloud_cover,band_links])\n", "\n", "dist_data_df = pd.DataFrame(dist_data_df, columns = ['TileID', 'Sensor', 'Date', 'Coords', 'bbox','SpatialCoverage','CloudCover','BandLinks'])\n", "dist_data_df" ] }, { "cell_type": "markdown", "id": "6789597a", "metadata": {}, "source": [ "## 3. Load and Visualize DIST-ALERT-HLS COGs from the Cloud" ] }, { "cell_type": "markdown", "id": "30380b94", "metadata": {}, "source": [ "If one tile is extracted from the filtered collection and its layers are examined, all 19 product layers are produced." ] }, { "cell_type": "code", "execution_count": 14, "id": "f5db5040", "metadata": {}, "outputs": [], "source": [ "# Instead of reading in band links, need to project to folium's projection and merge tiles\n", "\n", "# Need to implement transform_data_for_folium function in .py file\n", "T42RUR_VEG_ANOM_MAX, T42RUR_VEG_ANOM_MAX_cm = transform_data_for_folium(dist_data_df.iloc[0].BandLinks[4])\n", "T42RVR_VEG_ANOM_MAX, T42RVR_VEG_ANOM_MAX_cm = transform_data_for_folium(dist_data_df.iloc[1].BandLinks[4])\n", "merged_VEG_ANOM_MAX = merge_arrays([T42RUR_VEG_ANOM_MAX, T42RVR_VEG_ANOM_MAX])\n", "\n", "\n", "T42RUR_VEG_DIST_DATE, T42RUR_VEG_DIST_DATE_cm = transform_data_for_folium(dist_data_df.iloc[0].BandLinks[6])\n", "T42RVR_VEG_DIST_DATE, T42RVR_VEG_DIST_DATE_cm = transform_data_for_folium(dist_data_df.iloc[1].BandLinks[6])\n", "merged_VEG_DIST_DATE = merge_arrays([T42RUR_VEG_DIST_DATE, T42RVR_VEG_DIST_DATE])\n", "\n", "T42RUR_VEG_DIST_STATUS, T42RUR_VEG_DIST_STATUS_cm = transform_data_for_folium(dist_data_df.iloc[0].BandLinks[0])\n", "T42RVR_VEG_DIST_STATUS, T42RVR_VEG_DIST_STATUS_cm = transform_data_for_folium(dist_data_df.iloc[1].BandLinks[0])\n", "merged_VEG_DIST_STATUS = merge_arrays([T42RUR_VEG_DIST_STATUS, T42RVR_VEG_DIST_STATUS])" ] }, { "cell_type": "code", "execution_count": 15, "id": "332a6e29", "metadata": {}, "outputs": [], "source": [ "masked_VEG_ANOM_MAX, masked_VEG_DIST_DATE,masked_VEG_DIST_STATUS = mask_rasters(merged_VEG_ANOM_MAX, merged_VEG_DIST_DATE, merged_VEG_DIST_STATUS)\n", "\n", "colorized_VEG_ANOM_MAX = colorize(masked_VEG_ANOM_MAX[0])\n", "colorized_VEG_DIST_DATE = colorize(masked_VEG_DIST_DATE[0])\n", "colorized_VEG_DIST_STATUS = colorize(masked_VEG_DIST_STATUS[0])" ] }, { "cell_type": "code", "execution_count": 16, "id": "aa68131d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Initialize Folium basemap\n", "xmid =(merged_VEG_ANOM_MAX.x.values.min()+merged_VEG_ANOM_MAX.x.values.max())/2 ; ymid = (merged_VEG_ANOM_MAX.y.values.min()+merged_VEG_ANOM_MAX.y.values.max())/2\n", "m = folium.Map(location=[ymid, xmid], zoom_start=9, tiles='CartoDB positron', show=True)\n", "\n", "# Add custom basemaps\n", "basemaps = getbasemaps()\n", "for basemap in basemaps:\n", " basemaps[basemap].add_to(m)\n", "\n", "folium.raster_layers.ImageOverlay(colorized_VEG_ANOM_MAX, \n", " opacity=0.6, \n", " bounds=[[merged_VEG_ANOM_MAX.y.values.min(),merged_VEG_ANOM_MAX.x.values.min()],[merged_VEG_ANOM_MAX.y.values.max(),merged_VEG_ANOM_MAX.x.values.max()]],\n", " name='VEG_ANOM_MAX',\n", " show=True).add_to(m)\n", "\n", "folium.raster_layers.ImageOverlay(colorized_VEG_DIST_DATE, \n", " opacity=0.6, \n", " bounds=[[merged_VEG_DIST_DATE.y.values.min(),merged_VEG_DIST_DATE.x.values.min()],[merged_VEG_DIST_DATE.y.values.max(),merged_VEG_DIST_DATE.x.values.max()]],\n", " name='VEG_DIST_DATE',\n", " show=True).add_to(m)\n", "\n", "folium.raster_layers.ImageOverlay(colorized_VEG_DIST_STATUS, \n", " opacity=0.6, \n", " bounds=[[merged_VEG_DIST_STATUS.y.values.min(),merged_VEG_DIST_STATUS.x.values.min()],[merged_VEG_DIST_STATUS.y.values.max(),merged_VEG_DIST_STATUS.x.values.max()]],\n", " name='VEG_DIST_STATUS',\n", " show=True).add_to(m)\n", "\n", "#layer Control\n", "m.add_child(folium.LayerControl())\n", "\n", "# Add fullscreen button\n", "plugins.Fullscreen().add_to(m)\n", "\n", "#Add inset minimap image\n", "minimap = plugins.MiniMap(width=200, height=200)\n", "m.add_child(minimap)\n", "\n", "#Mouse Position\n", "fmtr = \"function(num) {return L.Util.formatNum(num, 3) + ' º ';};\"\n", "plugins.MousePosition(position='bottomright', separator=' | ', prefix=\"Lat/Lon:\",\n", " lat_formatter=fmtr, lng_formatter=fmtr).add_to(m)\n", "\n", "#Display\n", "m" ] } ], "metadata": { "kernelspec": { "display_name": "opera_app", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.12" }, "vscode": { "interpreter": { "hash": "d3f517887d494ca810b9ddd3e2c7769ba26125fbb50c0d317f4f8d676aa80e0e" } } }, "nbformat": 4, "nbformat_minor": 5 }