{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Classifying satellite data \n", "\n", "* **[Sign up to the DEA Sandbox](https://app.sandbox.dea.ga.gov.au/)** to run this notebook interactively from a browser\n", "* **Compatibility:** Notebook currently compatible with the `DEA Sandbox` environment\n", "* **Products used:** \n", "[ga_ls8c_nbart_gm_cyear_3](https://explorer.dea.ga.gov.au/products/ga_ls8c_nbart_gm_cyear_3),\n", "[ga_ls_fc_pc_cyear_3](https://explorer.dea.ga.gov.au/products/ga_ls_fc_pc_cyear_3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Description\n", "\n", "Having succesfully run the `3_Evaluate_optimize_fit_classifier` notebook, we can now use our classification model to predict values on new satellite data. This notebook will guide you through loading satellite data from the ODC, computing the same feature layers as we did in the first notebook when we extracted training data from the ODC, and using our model to classifying the satellite data. Initially we classify a few small regions to visualize how well our model is performing. The notebook will then attempt to classify a much larger region and save the results to disk as a Cloud-Optimized GeoTIFF (COG).\n", "\n", "The steps are as follows:\n", "1. Open the model we output in the previous notebook, `3_Evaluate_optimize_fit_classifier`\n", "2. Redefine the feature layer function that we used to extract training data from the ODC in the first notebook, `1_Extract_training_data`\n", "3. Loop through a set of small test locations extracting satellite data from the ODC, then compute the feature layers and classify the data using our model.\n", "4. Plot the results of classifying our small test locations\n", "5. Define a new, much larger location to load from the ODC and classify using the same model\n", "6. Save our results to disk as a COG\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "***\n", "## Getting started\n", "\n", "To run this analysis, run all the cells in the notebook, starting with the \"Load packages\" cell. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load Packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import datacube\n", "import xarray as xr\n", "from joblib import load\n", "import matplotlib.pyplot as plt\n", "from datacube.utils.cog import write_cog\n", "\n", "import sys\n", "sys.path.insert(1, '../../Tools/')\n", "from dea_tools.datahandling import load_ard\n", "from dea_tools.plotting import rgb, display_map\n", "from dea_tools.bandindices import calculate_indices\n", "from dea_tools.classification import predict_xr\n", "from dea_tools.dask import create_local_dask_cluster\n", "\n", "import warnings\n", "warnings.filterwarnings(\"ignore\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set up a dask cluster\n", "This will help keep our memory use down and conduct the analysis in parallel. If you'd like to view the dask dashboard, click on the hyperlink that prints below the cell. You can use the dashboard to monitor the progress of calculations." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n",
"Client\n", "
| \n",
"\n",
"Cluster\n", "
| \n",
"