IO¶
Regions¶
bathy.list_regions()
¶
List all available preset regions.
Returns:
| Type | Description |
|---|---|
list[str]
|
Sorted list of region names |
Examples:
>>> from bathy import list_regions
>>> regions = list_regions()
>>> print(regions[:5])
['arabian_sea', 'baltic_sea', 'bay_of_bengal', 'black_sea', 'caribbean']
Source code in src/bathy/io.py
Loading¶
bathy.load_bathymetry(filepath, lon_range=None, lat_range=None, region=None, var_name='elevation', lon_name='lon', lat_name='lat')
¶
Load bathymetry data from a NetCDF or GeoTIFF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str
|
Path to the file |
required |
lon_range
|
tuple[float, float]
|
Longitude bounds (min, max). Cannot be used with 'region'. |
None
|
lat_range
|
tuple[float, float]
|
Latitude bounds (min, max). Cannot be used with 'region'. |
None
|
region
|
str
|
Preset region name. See |
None
|
var_name
|
str
|
Variable name |
'elevation'
|
lon_name
|
str
|
Longitude coordinate name |
'lon'
|
lat_name
|
str
|
Latitude coordinate name |
'lat'
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Elevation data with 'lon' and 'lat' coordinates |
Examples:
>>> data = load_bathymetry('gebco.nc', lon_range=(-10, -5), lat_range=(50, 55))
>>> data = load_bathymetry('gebco.nc', region='mediterranean')
Source code in src/bathy/io.py
bathy.load_emodnet_wcs(lon_range=None, lat_range=None, region=None, save_path=None)
¶
Download bathymetry from the EMODnet Web Coverage Service.
EMODnet provides high-resolution (~115 m) gridded bathymetry for European seas. Coverage is limited to European maritime areas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon_range
|
tuple[float, float]
|
Longitude bounds (min, max). Cannot be used with 'region'. |
None
|
lat_range
|
tuple[float, float]
|
Latitude bounds (min, max). Cannot be used with 'region'. |
None
|
region
|
str
|
Preset region name. See |
None
|
save_path
|
str
|
If provided, save the downloaded GeoTIFF to this path for reuse. If the file already exists, it is loaded without downloading. If omitted, the data is downloaded to a temporary file that is automatically deleted after loading. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Elevation data with 'lon' and 'lat' coordinates |
References
EMODnet Bathymetry Consortium (2024). EMODnet Digital Bathymetry (DTM). https://emodnet.ec.europa.eu/en/bathymetry
Examples:
>>> data = load_emodnet_wcs(lon_range=(-10, -5), lat_range=(50, 55))
>>> data = load_emodnet_wcs(region='north_sea')
Source code in src/bathy/io.py
bathy.load_etopo(lon_range=None, lat_range=None, region=None, resolution='60s', save_path=None)
¶
Download NOAA ETOPO 2022 global relief data.
ETOPO provides integrated topography and bathymetry from NOAA NCEI, widely used by US-based and global researchers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon_range
|
tuple[float, float]
|
Longitude bounds (min, max). Cannot be used with 'region'. |
None
|
lat_range
|
tuple[float, float]
|
Latitude bounds (min, max). Cannot be used with 'region'. |
None
|
region
|
str
|
Preset region name. See |
None
|
resolution
|
str
|
Grid resolution: '60s' (1 arc-minute), '30s', or '15s'. |
'60s'
|
save_path
|
str
|
If provided, save the downloaded file to this path for reuse. If the file already exists, it is loaded without downloading. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Elevation data with 'lon' and 'lat' coordinates |
References
NOAA National Centers for Environmental Information (2022). ETOPO 2022 15 Arc-Second Global Relief Model. https://doi.org/10.25921/fd45-gt74
Examples:
>>> data = load_etopo(lon_range=(-10, -5), lat_range=(50, 55))
>>> data = load_etopo(region='mediterranean', resolution='30s')
Source code in src/bathy/io.py
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | |
bathy.load_gebco_opendap(lon_range=None, lat_range=None, region=None, year=2025, save_path=None)
¶
Download GEBCO data from OPeNDAP server for a specific region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon_range
|
tuple[float, float]
|
Longitude bounds (min, max), range: -180 to 180. Cannot be used with 'region'. |
None
|
lat_range
|
tuple[float, float]
|
Latitude bounds (min, max), range: -90 to 90. Cannot be used with 'region'. |
None
|
region
|
str
|
Preset region name. See |
None
|
year
|
int
|
GEBCO dataset year. Valid years: 2019-2025. |
2025
|
save_path
|
str
|
If provided, save the downloaded file to this path for reuse. If omitted, the data is downloaded to a temporary file that is automatically deleted after loading. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Elevation data |
Notes
Download size scales with the requested area. The full global grid is
~8 GB. For regions larger than ~500 MB, save_path is required to
avoid downloading to a temporary file. Large downloads will log a
warning with the estimated size.
References
GEBCO Compilation Group (2025) GEBCO 2025 Grid (doi:10.5285/37c52e96-24ea-67ce-e063-7086abc05f29)
Examples:
>>> data = load_gebco_opendap(lon_range=(-10, -5), lat_range=(50, 55))
>>> data = load_gebco_opendap(region='mediterranean')
>>> # Large region — use save_path to keep the file
>>> data = load_gebco_opendap(region='pacific', save_path='pacific.nc')
Source code in src/bathy/io.py
bathy.load_noaa_crm(lon_range=None, lat_range=None, region=None, save_path=None)
¶
Load NOAA Coastal Relief Model (~3 arc-second / ~90 m) via OPeNDAP.
High-resolution bathymetry/topography for US coastal waters. The correct CRM volume is selected automatically based on the requested region.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lon_range
|
tuple[float, float]
|
Longitude bounds (min, max). Cannot be used with 'region'. |
None
|
lat_range
|
tuple[float, float]
|
Latitude bounds (min, max). Cannot be used with 'region'. |
None
|
region
|
str
|
Preset region name. See |
None
|
save_path
|
str
|
If provided, save the subsetted data as NetCDF for reuse. If the file already exists, it is loaded without fetching. |
None
|
Returns:
| Type | Description |
|---|---|
DataArray
|
Elevation data with 'lon' and 'lat' coordinates |
Notes
Coverage is limited to US coastal waters (10 regional volumes).
Requesting a region outside US waters will raise a ValueError.
References
NOAA National Centers for Environmental Information. U.S. Coastal Relief Model. https://www.ngdc.noaa.gov/mgg/coastal/crm.html
Examples:
>>> data = load_noaa_crm(lon_range=(-72, -70), lat_range=(41, 43))
>>> data = load_noaa_crm(region='us_east_coast', save_path='crm.nc')
Source code in src/bathy/io.py
715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | |
Exporting¶
bathy.to_geotiff(data, filepath, crs=None, **kwargs)
¶
Save data to a GeoTIFF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Elevation data |
required |
filepath
|
str or Path
|
Output GeoTIFF file path |
required |
crs
|
str
|
Coordinate reference system. Only used when the data has no CRS
attached; defaults to |
None
|
**kwargs
|
Additional arguments passed to rioxarray.to_raster() |
{}
|
Examples: