NATURESCAPES shoreline analysis
Project description
NATURESCAPES shoreline Package
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 design rationale for the ray-casting mechanism (back-projection from the LAT line, wave shadow detection, the derived refractive ratio, and the snell/transect mode split) is documented in docs/ray_casting.md.
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,
wave_bearing=295, # compass bearing waves travel towards (0 north, 90 east); defaults to shore-normal swell
origin_distance=1500, # distance in m from the LAT line at which wave rays originate
mode="snell", # "snell" (default): wave rays for impact analysis; "transect": shore-normal transects for slope statistics
smoothing_window=500 # optional, transect-mode angle smoothing; defaults to 250
)
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 analysisanalysis_crs: The coordinate reference system usedlat/hat: Lowest/Highest Astronomical Tide valueslat_crs/hat_crs: Original CRS of LAT/HAT datawave_period/wave_height: Wave parametersray_resolution: Resolution of ray casting in metressmoothing_window: Window size used for transect-mode angle smoothingmode: "snell" or "transect"wave_bearing: Compass bearing waves travel towardsrefractive_index_ratio: Resolved Snell ratio at the LAT lineshadowed_vertices: Number of LAT vertices shadowed from the swell direction
Geometry Data
lat_line: GeoDataFrame containing the LAT (Lowest Astronomical Tide) lineshore_line: GeoDataFrame containing the HAT (Highest Astronomical Tide) shorelineorigin_rays: GeoDataFrame containing the original rays before intersectionslopes: GeoDataFrame containing the trimmed rays with calculated metrics (see below)shoaling: GeoDataFrame containing the line where waves begin shoalingbreaking: GeoDataFrame containing the line where waves breakintertidal: GeoDataFrame containing the intertidal zone polygonscore: GeoDataFrame containing a LineString with impact intensity scoresshadowed: GeoDataFrame of LAT vertices shadowed from the swell direction (snell mode)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 HATlength: Length of each ray in metresstart_depth/end_depth: Depths at LAT and HATslope: Gradient (rise/run)slope_degrees: Slope angle in degreesslope_radians: Slope angle in radiansslope_degrees_normalised: Normalised slope values (0-1)distance_to_breaking: Distance from HAT to breaking linedistance_to_shoaling: Distance from HAT to shoaling lineshoal_break_width: Width between shoaling and breaking linesshoal_extrapolated/break_extrapolated: True where the shoaling or breaking point lies seaward of the LAT line and was placed by extrapolating the intertidal slope. Real subtidal profiles are typically flatter, so these offshore distances are lower boundsconvergence: Shoreward convergence of the local ray bundle, the ratio of inter-ray spacing at the LAT line to the spacing at the HAT endpoints, averaged over each ray's neighbours. Values above 1 mean rays converge shoreward (wave-energy focusing, typical of bays under oblique swell); below 1, divergence. Its square root is the refraction coefficient K_r of classical wave-ray theory, so it can be used to scale local wave height (seedocs/ray_casting.md)impact_intensity: The min-max normalised slope angle (0-1, higher = more intense wave impact). With a constant rise (HAT minus LAT) across all rays, the intertidal slope is the only independent geometric variable per ray, and steeper slopes deliver wave energy closer to the shoreline. The distance columns above are deliberately not combined into this score: under min-max normalisation they collapse to identical values and the wave parameters cancel out. Scores are relative within a single analysis and not comparable across analyses
Summary Statistics
metrics: Array of calculated gradient metricsfriendly_metrics: Dictionary version of metrics with descriptive namespcbreaks: Percentile breakpoints used for visualisation [10, 25, 50, 75, 90, 95]
Methods
visualise_coastal_slopes(): Returns a tuple of (map_figure, stats_figure) for visualisationsummary_stats: Property that returns formatted summary statistics
Sample output from shoreline.ipynb (Dublin Bay)
Sample output of a ray intersecting isobaths ray_slope.ipynb
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shoreline-0.3.0.tar.gz.
File metadata
- Download URL: shoreline-0.3.0.tar.gz
- Upload date:
- Size: 52.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2d67f69e93ad391924575f967152ef66afcf12356d8a6d9de7c0347b2b0d4a6
|
|
| MD5 |
c93e524c4b292ed715dc6873875324cd
|
|
| BLAKE2b-256 |
35bf0b0891dbec4e265a02fca236eb34198f00bdd9b88224e707acfdae308400
|
Provenance
The following attestation bundles were made for shoreline-0.3.0.tar.gz:
Publisher:
test.yml on urschrei/naturescapes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shoreline-0.3.0.tar.gz -
Subject digest:
d2d67f69e93ad391924575f967152ef66afcf12356d8a6d9de7c0347b2b0d4a6 - Sigstore transparency entry: 1803664702
- Sigstore integration time:
-
Permalink:
urschrei/naturescapes@916b63e8c8fb7254d35a48a3a07bf9ffb9f6918a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/urschrei
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@916b63e8c8fb7254d35a48a3a07bf9ffb9f6918a -
Trigger Event:
push
-
Statement type:
File details
Details for the file shoreline-0.3.0-py3-none-any.whl.
File metadata
- Download URL: shoreline-0.3.0-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9652bd6414bb9f152602c89c7e6b18f8858a07280f091c7ef29dbc2376ebcf49
|
|
| MD5 |
37285e63b5c8588bd4cbab56576ddd40
|
|
| BLAKE2b-256 |
041cec00ce337955d0db02e8c52bf2ac37ad2bd6d561e54b1c81ff1cf03a2cdb
|
Provenance
The following attestation bundles were made for shoreline-0.3.0-py3-none-any.whl:
Publisher:
test.yml on urschrei/naturescapes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shoreline-0.3.0-py3-none-any.whl -
Subject digest:
9652bd6414bb9f152602c89c7e6b18f8858a07280f091c7ef29dbc2376ebcf49 - Sigstore transparency entry: 1803664915
- Sigstore integration time:
-
Permalink:
urschrei/naturescapes@916b63e8c8fb7254d35a48a3a07bf9ffb9f6918a -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/urschrei
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@916b63e8c8fb7254d35a48a3a07bf9ffb9f6918a -
Trigger Event:
push
-
Statement type: