{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# NDVI Phenology\n",
"\n",
"### Background\n",
"\n",
"Phenology is the study of how plant and animal life varies both with the season, and the climate more broadly. \n",
"\n",
"This notebook calculates vegetation phenology changes using Landsat-7 and/or Landsat-8 data. To detect changes in plant life, the algorithm uses the normalised difference vegetation index NDVI as a common proxy for vegetation growth and health. The output from this notebook can be used to assess differences in agriculture fields over time or space and also allow the assessment of growing states such as planting and harvesting. \n",
"\n",
"The output product is a statistical time series plot of NDVI with the data \"binned\" into weeks or months. The timeline can be changed from a single year (all data binned with the 12-month period) or spread out over the entire time window of the analysis. \n",
"\n",
"See this website for more information: https://phenology.cr.usgs.gov/ndvi_foundation.php"
]
},
{
"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 other required packages\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np \n",
"import xarray as xr \n",
"import pandas as pd\n",
"import datetime as dt"
]
},
{
"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": "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 = ('2007-01-01', '2009-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": [
"