Skip to main content

A package for calculating water storage based on global water body depth-area-volume equation and visualizing waterbody geometries.

Project description

Global Waterbody Calculator

Global Waterbody Calculator is an open-source Python package for estimating storage curves and bathymetry of freshwater bodies. Given a HydroLAKES ID or geographic coordinates, the tool fits global depth–area–volume (D-A-V) relationships, exports results, and generates high-resolution GeoTIFFs plus interactive 3-D visualizations.

PyPI License: MIT

Features

Capability Details
Global D-A & D-V retrieval Based on HydroLAKES, GLOBathy, GLRDAV
0.1 m resolution Area & volume at 0.1 m depth steps
Publication-ready plots CSV and PNG outputs
Bathymetric GeoTIFF Raster created from lake polygons
Interactive 3-D view Matplotlib/Plotly surface rendering

Installation

# PyPI
pip install globalwaterbodycalculator

Requirements

  • Python ≥ 3.7
  • Required packages (automatically installed via pip):
    • numpy
    • pandas
    • matplotlib
    • scipy
    • rasterio
    • scikit-learn
    • gdal
    • plotly
    • gdown

Ensure GDAL is installed and configured correctly on your system. It is required for raster and vector operations such as shapefile processing and TIFF output.

GDAL on Windows

On Windows, pip install globalwaterbodycalculator may fail while installing gdal with an error like:

fatal error C1083: Cannot open include file: 'gdal.h': No such file or directory

This means pip is trying to compile GDAL from source but cannot find the native GDAL headers and libraries. The simplest Windows path is to install a prebuilt GDAL wheel that matches your Python version and architecture before installing this package. For example, for CPython 3.11 on 64-bit Windows:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip setuptools wheel
python -m pip install https://wheelhouse.openquake.org/v3/windows/py311/GDAL-3.10.1-cp311-cp311-win_amd64.whl
python -m pip install globalwaterbodycalculator

Verify GDAL with:

python -c "from osgeo import gdal, ogr; print(gdal.VersionInfo())"

If you prefer a managed geospatial stack, install GDAL through OSGeo4W or conda-forge, or install the native GDAL headers/libraries before using pip.

Quick Start (Python API)

from globalwaterbodycalculator.calculator import WaterBodyCalculator

# Initialize the calculator
calculator = WaterBodyCalculator()

# Calculate area-volume relationships by waterbody ID
result_df, water_body_id = calculator.calculate_area_volume(id=7, depth=244)
calculator.save_results_to_csv(result_df, water_body_id, output_dir='.')
calculator.plot_results(result_df, water_body_id, output_dir='.')

# Alternatively, calculate using latitude and longitude
result_df, water_body_id = calculator.calculate_area_volume(latitude=45.59193, longitude=47.71771, depth=10)
calculator.save_results_to_csv(result_df, water_body_id, output_dir='.')
calculator.plot_results(result_df, water_body_id, output_dir='.')

Bathymetric Mapping and 3D Visualization

You can generate bathymetric maps and 3D plots from shapefiles:

# Generate bathymetric GeoTIFF and optionally plot 3D visualization
calculator.generate_bathymetry_tiff(
    lake_id=7,          # Hylak_id of the waterbody
    shapefile='lakes.shp',  # Location of the shp file
    id_field='Hylak_id',    # Name of the id column
    depth=244,          # Max depth of the waterbody
    output_dir='output/',
    plot_3d=True        # Set to True to write the 3D HTML output
)

This will:

  • Compute the depth raster from the lake polygon and fitted D-A relationship
  • Save the bathymetric map as a GeoTIFF
  • Write an interactive 3D HTML surface view of the lake basin
  • If "plot_3d" is not set to True (default=False), only a GeoTIFF file will be generated
  • To display the Matplotlib 3D view while generating the HTML output, pass show_3d=True

Input & Output

Item Format Description
Input
id or latitude, longitude int / float HydroLAKES ID or WGS-84 coordinates
depth float Maximum depth (m)
Lake polygon (optional) ESRI Shapefile Must include an id_field matching Hylak_id
Output
<id>_dav.csv CSV Depth, area (m²), volume (m³)
<id>_dav.png PNG Area / volume curves
<id>_bathy.tif GeoTIFF Bathymetric raster
<id>_3d.html HTML Interactive 3-D view (optional)

Directory Layout

globalwaterbodycalculator/
├─ calculator.py       # Python API
├─ cli.py              # command-line entry point
├─ data_manager.py     # equation CSV download/cache helper
└─ __init__.py

HydroLAKES Download & Licence

Global Waterbody Calculator does not redistribute the HydroLAKES shapefiles. To create bathymetric maps and 3D views, you must:

  1. Download the dataset from https://www.hydrosheds.org/products/hydrolakes.
  2. Unzip it into a local folder, such as ~/data/HydroLAKES/.
  3. Point the environment variable HYDROLAKES_DIR to that path or pass the folder to the CLI/API option --hydrolakes_path.

The equation CSV is downloaded on first use and cached under ~/.globalwaterbodycalculator/all_equations.csv.

Citation

Please cite Global Waterbody Calculator in your publications as:

@software{Yu_Wu_Liao_Zhuo_GWC_2025,
  author  = {Shengde Yu and Yukai Wu and Weikun Liao and Zhuo Zhijian},
  title   = {Global Waterbody Calculator},
  year    = {2025},
  version = {0.1.5},
  url     = {https://pypi.org/project/globalwaterbodycalculator/}
}

Yu, S., Wu, Y., Liao, W., & Zhuo, Z. (2025). Global Waterbody Calculator: A Python package for freshwater depth-area-volume estimation (Version 0.1.5) [Software]. https://pypi.org/project/globalwaterbodycalculator/

Authors

Shengde Yu — Ecohydrology Research Group, Department of Earth & Environmental Sciences, University of Waterloo, Waterloo, ON, Canada — s228yu@uwaterloo.ca

Yukai Wu — The Edward S. Rogers Sr. Department of Electrical & Computer Engineering, University of Toronto, Toronto, ON, Canada — yukai.wu@mail.utoronto.ca

Weikun Liao — Department of Chemical Engineering & Applied Chemistry, University of Toronto, Toronto, ON, Canada — weikun.liao@mail.utoronto.ca

Zhijian Zhuo — Department of Chemical Engineering & Applied Chemistry, University of Toronto, Toronto, ON, Canada — zhijian.zhuo@mail.utoronto.ca

Contributing

We ♥ pull requests! To contribute:

  1. Fork the repo and create your feature branch: git checkout -b my-feature.
  2. Commit your changes with clear messages: git commit -m "feat: add …".
  3. Run tests & linter: pytest and pre-commit run --all-files.
  4. Open a Pull Request – describe what you changed and why.

Coding style follows PEP 8; CI (GitHub Actions) must pass on Linux & Windows.

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

globalwaterbodycalculator-0.1.5.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

globalwaterbodycalculator-0.1.5-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file globalwaterbodycalculator-0.1.5.tar.gz.

File metadata

File hashes

Hashes for globalwaterbodycalculator-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e5718905a5fb25a4197ce45ee800784dc822c2f297b99414b7a82fd19029a45a
MD5 302020bf3274bda6bb906d2be3e71632
BLAKE2b-256 bed1d658794506073e2bb11d813c05fa68bcf563595f3b62c16b56bad8530667

See more details on using hashes here.

File details

Details for the file globalwaterbodycalculator-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for globalwaterbodycalculator-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d0aa7dc71e2f21108a1931eed7aef63adeb3380a0030fadf9db093bfe6af0630
MD5 d262cd2743cde39300b04ee5a693b94e
BLAKE2b-256 3e76977722917a1e593a197fb8a6ee49800cd83e5b3318ae462cc3ccedb68862

See more details on using hashes here.

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