Skip to main content

NATURESCAPES shoreline analysis

Project description

NATURESCAPES shoreline Package

PyPI - Format

This is the repo for the Naturescapes shoreline package and research notebooks.

Utilities for ray casting, working with LineString resolution, and clipping rays have been organized as a Python package in the src directory. The main interface is provided by the ShorelineAnalyzer class.

The minimum supported Python version is Python 3.10.

Usage (see shoreline.ipynb for example)

from shoreline import ShorelineAnalyzer

# Create a new analyzer
analyzer = ShorelineAnalyzer()
sa = ShorelineAnalyzer(
    crs="EPSG:25829",
    shoreline="geodata/ireland/gadm36_IRL_shp/gadm36_IRL_0.shp",
    tideline="geodata/cleanup/Calculated Contours Backup/vorf_lat_simplified.gpkg",
    hat=2.09,
    lat=-2.44,
    wave_period=3.0,
    wave_height=2.0,
    ray_resolution=10,
    smoothing_window=500, # optional, defaults to 250
    origin_angle=0, # angle at which waves travel towards LAT; 0 is north, positive is clockwise
    origin_distance=1500 # distance in m from LAT bbox at which wave rays originate 
)
analysis = sa.evaluate()
# we now have a result object containing analysis metadata (.metadata), as well as geometries
# and summary stats
# call help(analysis) for more

# we can plot results if we're using a notebook. pl is a tuple of Matplotlib figures
pl = analysis.visualise_coastal_slopes()
# this gives us a (map, stats) tuple. Each figure can be saved
pl[0].savefig("dublin.png", dpi=300, bbox_inches="tight")
# you can also call the analysis.summary_stats property
# the computed ray and slope DataFrame is available as analysis.ray_data

AnalysisResult Object Fields

The AnalysisResult object returned by sa.evaluate() contains the following fields:

Metadata

  • metadata: Dictionary containing analysis parameters including:
    • timestamp: ISO format timestamp of analysis
    • analysis_crs: The coordinate reference system used
    • lat/hat: Lowest/Highest Astronomical Tide values
    • lat_crs/hat_crs: Original CRS of LAT/HAT data
    • wave_period/wave_height: Wave parameters
    • ray_resolution: Resolution of ray casting in metres
    • smoothing_window: Window size used for smoothing

Geometry Data

  • lat_line: GeoDataFrame containing the LAT (Lowest Astronomical Tide) line
  • shore_line: GeoDataFrame containing the HAT (Highest Astronomical Tide) shoreline
  • origin_rays: GeoDataFrame containing the original rays before intersection
  • slopes: GeoDataFrame containing the trimmed rays with calculated metrics (see below)
  • shoaling: GeoDataFrame containing the line where waves begin shoaling
  • breaking: GeoDataFrame containing the line where waves break
  • intertidal: GeoDataFrame containing the intertidal zone polygon
  • score: GeoDataFrame containing a LineString with impact intensity scores
  • intersections: List of any ray intersections that were removed

The slopes DataFrame

This is the main analysis output containing trimmed rays with the following columns:

  • geometry: LineString geometries of rays from LAT to HAT
  • length: Length of each ray in metres
  • start_depth/end_depth: Depths at LAT and HAT
  • slope: Gradient (rise/run)
  • slope_degrees: Slope angle in degrees
  • slope_radians: Slope angle in radians
  • slope_degrees_normalised: Normalised slope values (0-1)
  • distance_to_breaking: Distance from HAT to breaking line
  • distance_to_shoaling: Distance from HAT to shoaling line
  • shoal_break_width: Width between shoaling and breaking lines
  • distance_to_breaking_normalised: Inverted normalised values (shorter = higher score)
  • distance_to_shoaling_normalised: Inverted normalised values (shorter = higher score)
  • shoal_break_width_normalised: Inverted normalised values (narrower = higher score)
  • geom_mean_normalised: Geometric mean of the four normalised metrics, representing overall impact intensity (higher = more intense)

Summary Statistics

  • metrics: Array of calculated gradient metrics
  • friendly_metrics: Dictionary version of metrics with descriptive names
  • pcbreaks: Percentile breakpoints used for visualisation [10, 25, 50, 75, 90, 95]

Methods

  • visualise_coastal_slopes(): Returns a tuple of (map_figure, stats_figure) for visualisation
  • summary_stats: Property that returns formatted summary statistics

Sample output from shoreline.ipynb (Dublin Bay)

Dublin Bay

Sample output of a ray intersecting isobaths ray_slope.ipynb

Ray / Slope

Installation

uv add shoreline or pip install shoreline

Installing for local development

This project is developed using uv, but should work with just pip. The use of a virtualenv is advised.

uv venv
source .venv/bin/activate
uv sync --all-extras

uv add --dev ipykernel
uv run ipython kernel install --user --env VIRTUAL_ENV $(pwd)/.venv --name=shoreline
uv run --with jupyter jupyter lab

When creating a notebook, select the shoreline kernel from the dropdown. Then use e.g. !uv add pydantic to add pydantic to the project's dependencies, or !uv pip install pydantic to install pydantic into the project's virtual environment without persisting the change to the project pyproject.toml or uv.lock files. Either command will make import pydantic work within the notebook

Anaconda

For Anaconda users: you will probably have to pull the requirements out of pyproject.toml. Sorry!

Testing

The smoothing algorithm is relatively well covered by tests (see tests/test_utils.py). Run pytest in the root dir in order to test if you'd like to tinker with it.

Data

Are in the geodata folder.

Copyright

Stephan Hügel / Naturescapes, 2025

Funding

The NATURESCAPES project is funded by the European Union under Grant Agreement No 10108434

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shoreline-0.2.2.tar.gz (38.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shoreline-0.2.2-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file shoreline-0.2.2.tar.gz.

File metadata

  • Download URL: shoreline-0.2.2.tar.gz
  • Upload date:
  • Size: 38.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for shoreline-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8c0aef378fb4106e7cb25d80f0a74ae372456918af132b0b15635c103d8f06e3
MD5 97ef2607cad822ae9247aae238af66b1
BLAKE2b-256 b2a4ef8b0d64c249ba44284c0c8e57e2978d6a344adb6758e237a73acc7129fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for shoreline-0.2.2.tar.gz:

Publisher: test.yml on urschrei/naturescapes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file shoreline-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: shoreline-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 36.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for shoreline-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b66bf2d3a8f3dbbbe7197b2c99be1cae11e124613e6cc464b77cb2a3598524cc
MD5 44d6aea238893b56101137a31ee3c273
BLAKE2b-256 3bc84ac9c8c9b37673d1a054359fc433854bc8cdc5fab7bacb6ea33bec5980fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for shoreline-0.2.2-py3-none-any.whl:

Publisher: test.yml on urschrei/naturescapes

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page