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.
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):
numpypandasmatplotlibscipygeopyrasterioscikit-learngdalplotlygdown
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 enable 3D plotting
)
This will:
- Compute the depth raster from the lake polygon and fitted D-A relationship
- Save the bathymetric map as a GeoTIFF
- Display an interactive 3D surface plot of the lake basin
- If "plot_3d" is not set to True (default=False), only a GeoTIFF file will be generated
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 ├─ equations/ # reference equations ├─ examples/ └─ docs/
HydroLAKES download & licence Global Waterbody Calculator does not redistribute the HydroLAKES shapefiles. "plot_3d" need to use Hydrolakes Shapefile. To run volume/area calculations or create maps you must:
Download the dataset from https://www.hydrosheds.org/products/hydrolakes.
Unzip it into a local folder (e.g. ~/data/HydroLAKES/).
Point the environment variable HYDROLAKES_DIR to that path or pass the folder to the API/CLI option --hydrolakes_path.
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 = {<current-version>},
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 <current-version>) [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:
- Fork the repo and create your feature branch:
git checkout -b my-feature. - Commit your changes with clear messages:
git commit -m "feat: add …". - Run tests & linter:
pytestandpre-commit run --all-files. - 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
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 globalwaterbodycalculator-0.1.4.tar.gz.
File metadata
- Download URL: globalwaterbodycalculator-0.1.4.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a7d293ec212a257c3223f8f25c6a2cd3acc90a53cd6cc07d31806909fd13241
|
|
| MD5 |
a79cc5033abea1edf6a3be02929c0893
|
|
| BLAKE2b-256 |
0e8edd9ccccdac60e7fb252aeaf3d132d800aa3cc29933a0618c5a793bc13d57
|
File details
Details for the file globalwaterbodycalculator-0.1.4-py3-none-any.whl.
File metadata
- Download URL: globalwaterbodycalculator-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7a66874ac21f9af83ce1e02729df09db28807236d7268b4818a39402557c443
|
|
| MD5 |
9dd12c94c4897baef44b93a9bfc3e8d8
|
|
| BLAKE2b-256 |
e93c95cd9f7f110a18d33d5dbef553abb698f1e679e927693e8084ffe1a68079
|