| Title: | Download and Extract BlueTopo Bathymetry with Terra |
| Version: | 0.0.1 |
| Description: | Discovers, downloads, verifies, and opens bathymetry assets from the National Oceanic and Atmospheric Administration (NOAA) BlueTopo product for user supplied areas of interest. The package keeps source files intact by default, uses 'terra' for spatial data access, supports explicit native-resolution selection policies, and records provenance for reproducible extraction workflows. It accesses the NOAA BlueTopo web service at https://noaa-ocs-nationalbathymetry-pds.s3.amazonaws.com/ and references product documentation at https://nauticalcharts.noaa.gov/data/bluetopo.html. |
| License: | MIT + file LICENSE |
| URL: | https://el-cordero.github.io/bluer-topo/, https://github.com/el-cordero/bluer-topo |
| BugReports: | https://github.com/el-cordero/bluer-topo/issues |
| Depends: | R (≥ 4.1), terra |
| Imports: | cli, curl, digest, jsonlite, stats, tools, utils, xml2 |
| Suggests: | knitr, lintr, pkgdown, pkgload, rmarkdown, roxygen2, sf, styler, testthat (≥ 3.0.0), urlchecker, withr |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/Needs/website: | r-lib/pkgdown |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-21 22:41:34 UTC; ec |
| Author: | Elvin Cordero [aut, cre, cph] |
| Maintainer: | Elvin Cordero <elvin.cordero@seamountgeo.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-04 16:30:22 UTC |
bluertopo: Download and extract NOAA BlueTopo bathymetry with terra
Description
bluertopo discovers NOAA BlueTopo source tiles, downloads original
GeoTIFF/RAT assets with checksum validation, and opens selected raster bands
as file-backed terra objects.
Author(s)
Maintainer: Elvin Cordero elvin.cordero@seamountgeo.com [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/el-cordero/bluer-topo/issues
Download and extract NOAA BlueTopo bathymetry
Description
bluertopo() is the main extraction workflow. It discovers BlueTopo tiles
for an AOI, downloads verified original source assets by default, and opens
selected bands as lazy, file-backed terra objects.
Usage
bluertopo(
aoi,
layers = "elevation",
resolution = "native",
coverage = "warn",
min_coverage = 1,
access = "download",
cache_dir = bluertopo_cache_dir(),
refresh = "if_stale",
crop = TRUE,
mask = FALSE,
combine = "auto",
output_crs = NULL,
output_resolution = NULL,
resampling = NULL,
verify = "sha256",
workers = NULL,
progress = interactive(),
quiet = FALSE,
details = FALSE
)
Arguments
aoi |
A polygonal area of interest in one of the formats listed in AOI inputs below. |
layers |
A character vector containing |
resolution |
A native source-tile selection policy. Supply a shortcut
such as |
coverage |
A character scalar controlling incomplete selected coverage:
|
min_coverage |
A numeric value from 0 through 1 giving the target share of published tile-index coverage. This is geometric catalog coverage, not a data-quality measure. |
access |
A character scalar. |
cache_dir |
A non-empty character path for the package cache. The session-temporary default avoids writing to the user's home directory. Set an explicit path to reuse catalogs, source files, and VRTs across sessions. |
refresh |
A character scalar controlling catalog access:
|
crop |
A length-one logical. If |
mask |
A length-one logical. If |
combine |
A character scalar controlling multiple native grids:
|
output_crs |
|
output_resolution |
|
resampling |
|
verify |
A character scalar download-verification mode: |
workers |
|
progress |
A length-one logical controlling routine download progress. |
quiet |
A length-one logical suppressing routine informational messages. |
details |
A length-one logical. If |
Value
A terra::SpatRaster, terra::SpatRasterCollection, or a
bluertopo_result list as described in Output behavior.
AOI inputs
aoi must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a
terra::SpatVector;an
sf::sfdata frame orsf::sfcgeometry vector;a
terra::SpatRaster, whose extent and CRS define the AOI;a
terra::SpatExtent, interpreted as longitude/latitude in EPSG:4326;a numeric
c(xmin, ymin, xmax, ymax)bounding box in EPSG:4326;a local vector-file path readable by
terra::vect(); ora WKT or GeoJSON character string, interpreted as EPSG:4326.
Remote AOI URLs are refused. Numeric bounding boxes must be ordered and fall within valid longitude/latitude bounds. Point and line geometries are not accepted as areas of interest.
Output behavior
Native source grids are preserved unless both output_crs and
output_resolution are supplied. With details = FALSE, the function
returns a terra::SpatRaster for one compatible grid or a
terra::SpatRasterCollection for multiple incompatible native grids. With
details = TRUE, it returns a bluertopo_result list containing:
-
data: the raster or raster collection; -
tiles: selected tile footprints and catalog metadata; -
downloads: one record per source asset; -
query: normalized request settings and query hash; -
coverage: geometric coverage diagnostics; and -
provenance: catalog, checksum, source, and vertical-reference records.
Examples
aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715)
# sf and sfc polygons with a known CRS can be passed directly:
# aoi <- sf::st_read("my_area.gpkg")
bathy <- bluertopo(aoi)
Clear package-owned cache content
Description
Deletes only the configured bluertopo package cache after path safeguards.
Usage
bluertopo_cache_clear(
cache_dir = bluertopo_cache_dir(),
confirm = interactive()
)
Arguments
cache_dir |
Length-one character path to a package-owned cache directory. |
confirm |
A length-one logical. Must be |
Value
A one-row data frame with cache_dir, removed_files, and
removed_bytes columns.
Examples
bluertopo_cache_clear(confirm = TRUE)
Locate the bluertopo cache directory
Description
Returns the configured package cache directory without creating it.
Usage
bluertopo_cache_dir()
Details
The default is a session-temporary directory so routine package calls do not
write to the user's home directory. Set options(bluertopo.cache_dir = ...)
when a persistent cache is wanted.
Value
A length-one character vector containing the normalized cache path.
Examples
bluertopo_cache_dir()
Download original NOAA BlueTopo assets for an AOI
Description
Discovers selected BlueTopo tiles, downloads original GeoTIFF files and optional RAT sidecars, verifies them, and writes download manifests.
Usage
bluertopo_download(
aoi,
path,
resolution = "native",
coverage = "warn",
min_coverage = 1,
rat = TRUE,
refresh = "if_stale",
verify = "sha256",
workers = NULL,
on_exists = "verify",
on_error = "stop",
retries = 3,
timeout = NULL,
dry_run = FALSE,
progress = interactive(),
quiet = FALSE,
cache_dir = bluertopo_cache_dir()
)
Arguments
aoi |
A polygonal area of interest in one of the formats listed in AOI inputs below. |
path |
A non-empty character path to the destination directory for the original source assets and generated CSV/JSON manifests. The argument is required; there is no default write location. |
resolution |
A native source-tile selection policy. Supply a shortcut
such as |
coverage |
A character scalar controlling incomplete selected coverage:
|
min_coverage |
A numeric value from 0 through 1 giving the target share of published tile-index coverage. This is geometric catalog coverage, not a data-quality measure. |
rat |
A length-one logical. If |
refresh |
A character scalar controlling catalog access:
|
verify |
A character scalar download-verification mode: |
workers |
|
on_exists |
A character scalar: |
on_error |
A character scalar: |
retries |
A positive whole number giving the maximum attempts per asset. |
timeout |
|
dry_run |
A length-one logical. If |
progress |
A length-one logical controlling routine download progress. |
quiet |
A length-one logical suppressing routine informational messages. |
cache_dir |
A non-empty character path for the package cache. The session-temporary default avoids writing to the user's home directory. Set an explicit path to reuse catalogs, source files, and VRTs across sessions. |
Value
A bluertopo_downloads data frame with one row per planned asset.
Important columns include tile_id, asset_type, source_url,
local_path, status, verification_mode, verified, byte counts,
checksums, attempts, and any recorded error. CSV and JSON copies are
written below path unless dry_run = TRUE.
AOI inputs
aoi must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a
terra::SpatVector;an
sf::sfdata frame orsf::sfcgeometry vector;a
terra::SpatRaster, whose extent and CRS define the AOI;a
terra::SpatExtent, interpreted as longitude/latitude in EPSG:4326;a numeric
c(xmin, ymin, xmax, ymax)bounding box in EPSG:4326;a local vector-file path readable by
terra::vect(); ora WKT or GeoJSON character string, interpreted as EPSG:4326.
Remote AOI URLs are refused. Numeric bounding boxes must be ordered and fall within valid longitude/latitude bounds. Point and line geometries are not accepted as areas of interest.
Examples
aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715)
files <- bluertopo_download(
aoi,
path = file.path(tempdir(), "bluertopo-downloads")
)
Construct a BlueTopo native-resolution policy
Description
bluertopo_resolution() creates an explicit native source-tile selection
policy. Smaller meter values are finer source resolution. This object never
requests output resampling; use output_resolution in bluertopo() for an
explicit output grid.
Usage
bluertopo_resolution(
strategy,
value = NULL,
values = NULL,
min_m = NULL,
max_m = NULL,
n = NULL,
scope = "global",
tie = "finer",
prefer = "finest",
strict = TRUE,
min_coverage = 1
)
Arguments
strategy |
A character scalar naming a strategy: |
value |
|
values |
|
min_m, max_m |
|
n |
|
scope |
A character scalar. Only |
tie |
A character scalar, |
prefer |
A character scalar, |
strict |
A length-one logical. If |
min_coverage |
A numeric value from 0 through 1 used by the
|
Value
A bluertopo_resolution S3 object containing the normalized policy
fields. Pass it to the resolution argument of bluertopo(),
bluertopo_tiles(), or bluertopo_download().
Examples
bluertopo_resolution("nearest", value = 10, tie = "finer")
bluertopo_resolution("between", min_m = 4, max_m = 16)
Retrieve all BlueTopo tile polygons
Description
Downloads or reuses the current NOAA BlueTopo tile-scheme catalog and returns every published tile footprint. This function does not require an area of interest and does not download any bathymetry rasters.
Usage
bluertopo_tile_polygons(
cache_dir = bluertopo_cache_dir(),
refresh = "if_stale",
quiet = FALSE
)
Arguments
cache_dir |
A non-empty character path for the package cache. The session-temporary default avoids writing to the user's home directory. Set an explicit path to reuse catalogs, source files, and VRTs across sessions. |
refresh |
A character scalar controlling catalog access:
|
quiet |
A length-one logical suppressing routine informational messages. |
Value
A terra::SpatVector containing all current BlueTopo tile polygons
and their standardized catalog metadata, including tile ID, native
resolution, UTM zone, source URLs, and expected SHA-256 checksums.
Examples
tile_polygons <- bluertopo_tile_polygons()
Discover BlueTopo tiles intersecting an AOI
Description
Returns selected NOAA BlueTopo tile footprints and standardized metadata without downloading raster assets.
Usage
bluertopo_tiles(
aoi,
resolution = "native",
coverage = "warn",
min_coverage = 1,
cache_dir = bluertopo_cache_dir(),
refresh = "if_stale",
quiet = FALSE
)
Arguments
aoi |
A polygonal area of interest in one of the formats listed in AOI inputs below. |
resolution |
A native source-tile selection policy. Supply a shortcut
such as |
coverage |
A character scalar controlling incomplete selected coverage:
|
min_coverage |
A numeric value from 0 through 1 giving the target share of published tile-index coverage. This is geometric catalog coverage, not a data-quality measure. |
cache_dir |
A non-empty character path for the package cache. The session-temporary default avoids writing to the user's home directory. Set an explicit path to reuse catalogs, source files, and VRTs across sessions. |
refresh |
A character scalar controlling catalog access:
|
quiet |
A length-one logical suppressing routine informational messages. |
Value
A terra::SpatVector with selected tile metadata. Coverage
diagnostics are attached as the "coverage" attribute and the normalized
native-resolution policy as "resolution_spec". Important fields include
tile ID, native resolution, UTM zone, delivery date, intersection area and
fraction, source URLs, expected SHA-256 checksums, selection rank/reason,
and whether the tile was added as a coverage fallback.
AOI inputs
aoi must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a
terra::SpatVector;an
sf::sfdata frame orsf::sfcgeometry vector;a
terra::SpatRaster, whose extent and CRS define the AOI;a
terra::SpatExtent, interpreted as longitude/latitude in EPSG:4326;a numeric
c(xmin, ymin, xmax, ymax)bounding box in EPSG:4326;a local vector-file path readable by
terra::vect(); ora WKT or GeoJSON character string, interpreted as EPSG:4326.
Remote AOI URLs are refused. Numeric bounding boxes must be ordered and fall within valid longitude/latitude bounds. Point and line geometries are not accepted as areas of interest.
Examples
aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715)
tiles <- bluertopo_tiles(aoi)