sandpyper: A Python package for UAV-SfM beach volumetric and behavioural analysis

Sandpyper is a Python package that automates profile-based volumetric and altimetric sandy beaches analysis from a large amount of digital surface models and orthophotos. It includes functionalities to facilitate the cleaning of the elevation data from unwanted non-sand points or swash areas (where waves run up on the beach slope and 3D reconstruction is inaccurate) and to model beachface behavioural regimes using the Beachface Cluster Dynamics indices.


Introduction
Coastal zones host 40% of the world population (Martıńez et al., 2007) with continued expected growth to be focused in least developed countries (Neumann et al., 2015). Sandy beaches, amongst other ecoservices (Barbier et al., 2011), protect inland assets from coastal erosion, dissipating stormy waves energy on their shores. Mitigating beach erosion typically involves the establishment of topographic monitoring programs in key locations (erosional hotspots) to quantify beach dynamics, erosion/deposition volumes, recovery times and model coastal resilience or risk to erosion Ruessink et al. (2019). High temporal and spatial resolution topographic data is ideal, but expensive with most of the ordinary beach surveying methods. Unoccupied Aerial Vehicles (UAVs) and Structure from Motion algorithms (UAV-SfM) are emerging as ideal platform and methodology to obtain cost-effective high-quality beach topographic data (as Digital Surface Models, DSMs; Gonçalves & Henriques, 2015) at the mesoscale, which is an appropriate spatiotemporal scale for coastal managers to work with (Thom et al., 2018). Consequently, researchers already use UAV-SfM to monitor beach dynamics around the world Jaud et al. (2019), but it has been limited so far to a few sites and a few multitemporal dates. However more recently, UAV-SfM technology is being increasingly used for wider-scale and longer-term monitoring projects. For instance in Victoria (Australia), a citizen-science UAV-SfM monitoring program mobilises more than 150 volunteers to fly UAVs on 15 sites every six weeks during the last three years. To date, volunteers flew 350 times, enabling the creation of a DSM and an orthophoto per survey (uncompressed file sizes from 5-100 Gb each). Citizen scientists and SfM are generating an unprecedented archive of imagery which can be reliably used to monitor high-frequency sandy beach volumetric dynamics and behaviors .

Statement of Need
A drawback of using UAV-SfM for beach monitoring is that due to UAV regulations, flight altitude is often limited to around 80-120 m above ground, which means that the ground sampling distance of consumer-grade UAVs is sub-decimeter, resulting in very high resolution and large imagery files, especially for beach surveys exceeding the 20 ha coverage. Although managing tens of large rasters with Geographic Information Systems (GIS) such as QGIS (QGIS Development Team, 2021) or ESRI ArcGIS is technically feasible, handling tens to hundreds of such files within large monitoring projects quickly becomes impractical. Moreover, in coastal management, erosion assessments from multitemporal DSMs are usually approached by raster subtraction, also known as DEM of difference method (Lane et al., 2000). This is a process to compute elevation difference between time intervals by subtracting the elevation value of each cell in the pre and post rasters. Raster-based operations with full-resolution UAV-SfM imagery becomes very time consuming with important computing power and memory needs that can limit their feasibility. Therefore, tradeoffs for working within a GIS could include raster spatial downsampling, which might cause losing important information about equally important smaller scale geomorphological landforms (Walker et al., 2017), or, tiling the rasters into smaller and more manageable units, which ultimately further increases total pre-processing time. Furthermore, beach-specific challenges are (1) the water motion as waves wash in and out of the swash zone, which prevents SfM algorithm from modelling elevation accurately, (2) dune vegetation and (3) stranded beach wracks (macroalgae, woody debris), which requires time consuming manual processing to remove or filter to avoid biasing sediment volumetric computations.
Sandpyper is an open-source Python package that provides users with a processing pipeline specifically designed to overcome the aforementioned limitations, from the generation of crossshore transects and extraction of colour and elevation information from a collection of rasters, to the analysis of period-specific limits of detection and plotting of beachface cluster dynamics indices. It offers users the possibility to perform volumetric and behavioural monitoring of beaches in a programmatic and organised way at the location and single transect scale. Moreover, by using a naming convention, it allows to manage multiple locations with different coordinate reference systems. Although originally developed for coastal areas, Sandpyper can be applied in many other environments where DSMs and orthophotos timeseries are used to monitor changes, such as river levee, glacier or gully monitoring.
Some previous works that are somehow related to Sandpyper include Pybeach (Beuzen, 2019), a tool to automate beach dune toe identification and the Digital Shoreline Analysis System (DSAS), a tool to analyse shoreline shifts over time. While Pybeach is no longer maintained, the popularity of DSAS within the coastal erosion studies is fueled by its simple to use interface and the availability of a plug-in for ESRI ArcMap GIS. However, despite Sandpyper's planned expansion to study satellite-derived-shorelines with a method inspired by DSAS, DSAS core objective is the study of horizontal shoreline migrations over time, with no functionalities in terms of three-dimensional profile extraction, volumetric and altimetric analysis or behavioural modeling. To the best of the authors knowledge, this is the first Python package with the specific aim to integrate within an erosion monitoring project employing UAVs and SfM. Moreover, it is the only package which currently implements the Beachface Cluster Dynamics indices (BCDs) computation, which are purposefully designed novel metrics to leverage the very high spatiotemporal resolutions and three-dimensionality of UAV SfM topographic data for quantifying subaerial beach morphodynamics .
Sandpyper currently provides the ability to: • automatically create user-defined georeferenced cross-shore transects ( Figure 1A) along a line and extract elevation (from DSMs) and colour (from orthophotos) profiles. • facilitate unsupervised machine learning sand classification ( Figure 1B) and profile masking. • compute altimetric and volumetric timeseries analysis and plotting the results, at the transect ( Figure 1C) and site scales ( Figure 1D). • use spatial autocorrelation measures to discard spatial outliers and obtain statistically significant Hotspots/Coldspots areas of beach change at the site scale ( Figure 2A).
• compute first-order transition probabilities of magnitude of change classes ( Figure 2B) to derive BCDs ( Figure 2C).
Moreover, Sandpyper is being currently developed to include raster-based volumetric and behavioural analysis and satellite-derived shorelines analysis. Some features already in Sandpyper are: • custom spatial grid generation along a line (waterline, shoreline).
• shoreline error assessments in respect to groundtruth shorelines. • shoreline shifts statistics.
Sandpyper is aimed at being further developed to be a wider-scope package as it can be applied to any scope involving the extraction of information from a large amount of rasters.

Usage
Various tutorials and documentation are available for using Sandpyper, including: