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_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
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: