{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Cloud-Filtered Custom Mosaics\n",
"\n",
"### Background\n",
"\n",
"A mosaic is a composite image created by combining the most appropriate pixels from a collection of source images. A common use case is to create cloud-free images for applications that are not time-dependent. \n",
"\n",
"This notebook can be used to create custom Landsat cloud-filtered mosaics for any time period and location. The mosaics can be output as GeoTIFF products for analysis in external GIS tools. The following mosaics are possible:\n",
"\n",
"* Median = midpoint of spectral data\n",
"* Geomedian = Australian median product with improved spectral consistency\n",
"* Most-Recent = most-recent clear pixel\n",
"* Max-NDVI = maximum vegetation response\n",
"\n",
"Users should review the [Cloud Statistics](DCAL_Cloud_Statistics.ipynb) notebook for more information about the cloud statistics for any given temporal and spatial combination. An understanding of the underlying data is important for creating a valid mosaic for further analyses."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Preliminary steps"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Supress Warning \n",
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Load Data Cube Configuration\n",
"import datacube\n",
"dc = datacube.Datacube(app='my_app')\n",
"\n",
"# Import Data Cube API\n",
"import utils.data_cube_utilities.data_access_api as dc_api \n",
"api = dc_api.DataAccessApi()\n",
"\n",
"# Import Data Cube RGB plotting functionality\n",
"from utils.data_cube_utilities.dc_rgb import rgb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Define product and extent"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Available extents\n",
"\n",
"We've listed the available ingested data that you can explore in the ODC Sandbox. The latitude, longitude and time ranges correspond to the boundaries of the ingested data cubes. You'll be able to explore sub-samples of these cubes. You'll also need to provide the platform, product and resolution information for the cube you're subsampling.\n",
"\n",
"#### LS8 Caqueta\n",
"Platform: `'LANDSAT_8'`
\n",
"Product: `'ls8_collection1_AMA_ingest'`
\n",
"Latitude: `(0.000134747292617865, 1.077843593651382)`
\n",
"Longitude: `(-74.91935994831539, -73.30266193148462)`
\n",
"Time: `('2013-04-13', '2018-03-26')`
\n",
"Resolution: `(-0.000269494585236, 0.000269494585236)`\n",
"\n",
"#### LS8 Vietnam\n",
"Platform: `'LANDSAT_8'`
\n",
"Product: `'ls8_collection1_AMA_ingest'`
\n",
"Latitude: `(10.513927001104687, 12.611133863411238)`
\n",
"Longitude: `(106.79005909290998, 108.91906631627438)`
\n",
"Time: `('2014-01-14', '2016-12-21')`
\n",
"Resolution: `(-0.000269494585236, 0.000269494585236)`
\n",
"\n",
"#### LS7 Caqueta\n",
"Platform: `'LANDSAT_7'`
\n",
"Product: `'ls7_collection1_AMA_ingest'`
\n",
"Latitude: `(0.000134747292617865, 1.077843593651382)`
\n",
"Longitude: `(-74.91935994831539, -73.30266193148462)`
\n",
"Time: `('1999-08-21', '2018-03-25')`
\n",
"Resolution: `(-0.000269494585236, 0.000269494585236)`\n",
"\n",
"#### LS7 Lake Baringo\n",
"Platform: `'LANDSAT_7'`
\n",
"Product: `'ls7_collection1_AMA_ingest'`
\n",
"Latitude: `(0.4997747685, 0.7495947795)`
\n",
"Longitude: `(35.9742163305, 36.473586859499996)`
\n",
"Time: `('2005-01-08', '2016-12-24')`
\n",
"Resolution: `(-0.000269493, 0.000269493)`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set product information\n",
"\n",
"You can change the values in this cell to specify the product you wish to analyse."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# CHANGE HERE >>>>>>>>>>>>>>>>>\n",
"\n",
"# Select a product and platform\n",
"platform = \"LANDSAT_7\"\n",
"product = 'ls7_collection1_AMA_ingest'\n",
"resolution = (-0.000269494585236, 0.000269494585236)\n",
"output_crs = 'EPSG:4326'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set extent information\n",
"\n",
"You can change the values in this cell to specify the extent of the data cube you wish to analyse.\n",
"\n",
"You should select a sub-sample from one of the four data cubes listed above. When subsampling, keep in mind that:\n",
"* Your latitude and longitude bounds should be within the extents given.\n",
"* Your area should be small to keep load times reasonable (less than 0.5 square degrees).\n",
"* Your time period should be within the extents given.\n",
"\n",
"You should format the variables as:\n",
"* `latitude = (min_latitude, max_latitude)`\n",
"* `longitude = (min_longitude, max_longitude)`\n",
"* `time_extents = (min_time, max_time)`, where each time has the format: `'YYYY-MM-DD'`."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# CHANGE HERE >>>>>>>>>>>>>>>>>>\n",
"\n",
"# Select a sub-region to analyse\n",
"latitude = (0.49964002, 0.74964002)\n",
"longitude = (36.0, 36.3)\n",
"time_extents = ('2016-01-01', '2018-01-01')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### View the region before loading\n",
"\n",
"The next cell will allow you to view the area you'll be analysing by displaying a red bounding box on an interactive map. You can change the extents in the previous cell and rerun the `display_map()` command to see the resulting bounding box."
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"