<jupyter_start><jupyter_text>Introduction to DEA Coastlines * [**Sign up to the DEA Sandbox**](https://docs.dea.ga.gov.au/setup/sandbox.html) to run this notebook interactively from a browser* **Compatibility:** Notebook currently compatible with both the `NCI` and `DEA Sandbox` environments* **Products used:** [DEA Coastlines](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlines) BackgroundAustralia has a highly dynamic coastline of over 30,000 km, with over 85% of its population living within 50 km of the coast. This coastline is subject to a wide range of pressures, including extreme weather and climate, sea level rise and human development. Understanding how the coastline responds to these pressures is crucial to managing this region, from social, environmental and economic perspectives.  What this product offers[Digital Earth Australia Coastlines](https://maps.dea.ga.gov.au/share=s-DEACoastlines&playStory=1) is a continental dataset that includes annual shorelines and rates of coastal change along the entire Australian coastline from 1988 to the present. The product combines satellite data from Geoscience Australia's Digital Earth Australia program with tidal modelling to map the typical location of the coastline at mean sea level for each year. The product enables trends of coastal erosion and growth to be examined annually at both a local and continental scale, and for patterns of coastal change to be mapped historically and updated regularly as data continues to be acquired. This allows current rates of coastal change to be compared with that observed in previous years or decades. The ability to map shoreline positions for each year provides valuable insights into whether changes to our coastline are the result of particular events or actions, or a process of more gradual change over time. This information can enable scientists, managers and policy makers to assess impacts from the range of drivers impacting our coastlines and potentially assist planning and forecasting for future scenarios.  Applications* Monitoring and mapping rates of coastal erosion along the Australian coastline * Prioritise and evaluate the impacts of local and regional coastal management based on historical coastline change * Modelling how coastlines respond to drivers of change, including extreme weather events, sea level rise or human development * Supporting geomorphological studies of how and why coastlines have changed across time  Publications* <NAME>., <NAME>., <NAME>., <NAME>. (2021). Mapping Australia's dynamic coastline at mean sea level using three decades of Landsat imagery. *Remote Sensing of Environment*, 267, 112734. Available: https://doi.org/10.1016/j.rse.2021.112734* <NAME>., <NAME>., <NAME>., <NAME>., & <NAME>. (2019). Sub-pixel waterline extraction: Characterising accuracy and sensitivity to indices and spectra. *Remote Sensing*, 11(24), 2984. Available: https://www.mdpi.com/2072-4292/11/24/2984> **Note:** For more technical information about the DEA Coastlines product, visit the official Geoscience Australia [DEA Coastlines product description](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlines). DescriptionThis notebook will demonstrate how to load data from the [Digital Earth Australia Coastlines](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlines) product using the Digital Earth Australia datacube. Topics covered include:1. Loading DEA Coastlines annual shoreline data using the `get_coastlines` function.1. Loading DEA Coastlines rates of change statistics data using the `get_coastlines` function.2. Extracting shoreline data for one or multiple coastal transects using an interactive DEA Coastlines application.***  Getting startedTo run this analysis, run all the cells in the notebook, starting with the "Load packages" cell.  Load packages<jupyter_code>import geopandas as gpd
import matplotlib.pyplot as plt

import sys
sys.path.insert(1, '../Tools/')
from dea_tools.coastal import get_coastlines
from dea_tools.app import deacoastlines<jupyter_output><empty_output><jupyter_text>Loading DEA Coastlines data  Annual shorelinesDEA Coastlines data can be loaded directly in a Python script or Jupyter Notebook using the DEA Coastlines Web Feature Service (WFS) and `geopandas`:<jupyter_code># Specify bounding box
ymax, xmin = -33.65, 115.28
ymin, xmax = -33.66, 115.30

# Load DEA Coastlines annual shorelines data 
deacl_shorelines_gdf = get_coastlines(bbox=(xmin, ymin, xmax, ymax), 
                                      layer='shorelines')

# Print example output
deacl_shorelines_gdf.head()<jupyter_output><empty_output><jupyter_text>We can now plot the DEA Coastlines annual shoreline data using `geopandas`. Zoom in to **Bussleton** in Western Australia on the interactive map to view the shoreline data.Annual shorelines represent the median or 'most representative' position of the shoreline at approximately mean sea level tide (0 m Above Mean Sea Level) for each year from 1988 onward.Light-coloured lines (e.g. yellow) in the plot below represent recent shorelines (e.g. 2019), while dark-coloured lines represent older shorelines (e.g. 1988).> **Note:** For more detail about DEA Coastlines annual shoreline data, refer to the official Geoscience Australia [DEA Coastlines product description](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlinesdetails).<jupyter_code># Plot on interactive map of DEA Coastlines data within our bounding box
deacl_shorelines_gdf.explore(column='year', cmap='inferno', categorical=True)<jupyter_output><empty_output><jupyter_text>Rates of change statistics pointsWe can also load and plot the DEA Coastlines rates of change statistics points.These points provide robust rates of annual coastal change (in metres per year) for every 30 m along Australia's non-rocky (e.g. sandy and muddy) coastlines. These rates are calculated by linearly regressing annual shoreline positions against time, using the most recent shoreline as a baseline.Negative values (red points) indicate retreat (e.g. erosion), and positive values indicate growth (e.g. progradation) over time.By default, rates of change are shown for points with a statistically significant trend over time only.> **Note:** For more detail about DEA Coastlines rates of change statistics data, refer to the official Geoscience Australia [DEA Coastlines product description](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlinesdetails).<jupyter_code># Load DEA Coastlines annual shorelines data within our bounding box
deacl_statistics_gdf = get_coastlines(bbox=(xmin, ymin, xmax, ymax),
                                      layer='statistics')

# Filter points to statistically significant results only
deacl_statistics_gdf = deacl_statistics_gdf.loc[
    deacl_statistics_gdf.sig_time < 0.01]

# Plot on interactive map
deacl_statistics_gdf.explore(column='rate_time',
                             cmap='RdBu',
                             vmin=-3,
                             vmax=3,
                             tooltip='rate_time')<jupyter_output><empty_output><jupyter_text>The DEA Coastlines rates of change statistics points data also provides many additional statistics that give insights into coastal change in Australia.For a full description of each of these statistics, refer to the Rates of change statistics section of the official Geoscience Australia [DEA Coastlines product description](https://cmi.ga.gov.au/data-products/dea/581/dea-coastlinesdetails).<jupyter_code>deacl_statistics_gdf.head()<jupyter_output><empty_output><jupyter_text>Exporting DEA Coastlines data as vector filesWe can easily export the loaded data as spatial vector files (e.g. ESRI Shapefiles or GeoJSON) so that they can be analysed further in GIS software:<jupyter_code>deacl_shorelines_gdf.to_file('deacoastlines_shorelines.shp')
deacl_statistics_gdf.to_file('deacoastlines_statistics.shp')<jupyter_output><empty_output><jupyter_text>DEA Coastlines analysis toolsThe following sections provide useful tools for analysing DEA Coastlines data directly within a Jupyter Notebook without needing to load the data into GIS software.All outputs from the tools below will be saved to a new folder in this directory called `deacoastlines_outputs`. Extract shoreline data by coastal transectThis tool allows you to interactively draw a transect over DEA Coastlines annual shoreline data, and get back a graph showing how shoreline positions have changed over time.To use the tool:1. Run the cell below; an interactive application will appear 2. Zoom in on the map and use the `Draw a polyline` tool on the left to draw a transect so that it crosses through a set of shorelines (see example below). Transects should be drawn in a consistent direction, e.g. starting on land and finishing over water. This ensures that results can be compared between transects.![Transect example](../Supplementary_data/DEA_Coastlines/deacoastlines_transect.jpg)3. Press `Finish` when you are happy with the line, then click `Done` in the top right4. A graph will appear below the map showing distances along the transect to each annual shoreline (distances will be measured from the start of the transect line you drew above)> **Optional:** Set transaction extraction mode to `'width'` and re-run the cell below to measure the width between two adjacent sets of coastlines (e.g. across the neck of a tombolo or sandbar). > **Optional:** Upload a GeoJSON or ESRI Shapefile containing transects using the `Upload` button to automatically extract shoreline positions from multiple coastal transects (uploaded files should be less than 5 megabytes in size).<jupyter_code>deacoastlines.transect_app()<jupyter_output><empty_output><jupyter_text>The resulting figure shows how shorelines at this location have changed over time.In `distance` mode, the y-axis shows the distance from the start of the transect to the location at which the transect intersects with each annual shoreline (shown on the x-axis).If transects were drawn with a starting point on land, decreasing distances over time indicate the coastline at this location was retreating or eroding since 1988.Conversely, increasing distances over time indicate the coastline was growing.In `width` mode, the y-axis shows the distance (i.e. width) between the first and last time the transect intersects each annual shoreline. Increasing widths indicate that a sandbar, spit or peninsular was growing wider over time; decreasing widths indicate that it was eroding or growing narrower.  Next steps: coastline erosion notebookThe [Coastal erosion notebook](../Real_world_examples/Coastal_erosion.ipynb) in this repository provides a simplified example of the method used to extract DEA Coastlines annual shoreline data. Run this notebook if you would like to generate more customised coastlines for a specific location, time period, epoch (e.g. annual or biennial coastlines) or tidal range (e.g. the position of the coastline at low, mid  or high tide).> **Note:** This notebook currently supports extracting coastline data only, not generating rates of change statistics like those included in the DEA Coastlines product. --- Additional information**License:** The code in this notebook is licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). Digital Earth Australia data is licensed under the [Creative Commons by Attribution 4.0](https://creativecommons.org/licenses/by/4.0/) license.**Contact:** If you need assistance, please post a question on the [Open Data Cube Slack channel](http://slack.opendatacube.org/) or on the [GIS Stack Exchange](https://gis.stackexchange.com/questions/ask?tags=open-data-cube) using the `open-data-cube` tag (you can view previously asked questions [here](https://gis.stackexchange.com/questions/tagged/open-data-cube)).If you would like to report an issue with this notebook, you can file one on [Github](https://github.com/GeoscienceAustralia/dea-notebooks).**Last modified:** January 2022  TagsBrowse all available tags on the DEA User Guide's [Tags Index](https://docs.dea.ga.gov.au/genindex.html)<jupyter_code>**Tags**: :index:`NCI compatible`, :index:`sandbox compatible`, :index:`DEA Coastlines`, :index:`coastal erosion`, :index:`widgets`, :index:`ipyleaflet`, :index:`geopandas`, :index:`WFS`, :index:`dea datasets`, :index:`no_testing`<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06871770025839793, 'fraction_numerical': 0.01227390180878553, 'mean_word_length': 5.1832251622566154, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 48, 'https://': 16, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '115201', 'license': 'Apache-2.0', 'n_tokens_mistral': 3381, 'n_tokens_neox': 3159, 'n_words': 1472, 'path': 'DEA_datasets/DEA_Coastlines.ipynb', 'repo_name': 'mickwelli/dea-notebooks', 'size': '12429'}