| Title: | Download and Extract BlueTopo Bathymetry with Terra |
|---|---|
| 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>. |
| Authors: | Elvin Cordero [aut, cre, cph] |
| Maintainer: | Elvin Cordero <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.2 |
| Built: | 2026-10-06 11:00:56 UTC |
| Source: | https://github.com/el-cordero/bluer-topo |
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.
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 )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 )
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 |
A terra::SpatRaster, terra::SpatRasterCollection, or a
bluertopo_result list as described in Output behavior.
aoi must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a terra::SpatVector;
an sf::sf data frame or sf::sfc geometry 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(); or
a 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.
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.
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)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)
Deletes only the configured bluertopo package cache after path safeguards.
bluertopo_cache_clear( cache_dir = bluertopo_cache_dir(), confirm = interactive() )bluertopo_cache_clear( cache_dir = bluertopo_cache_dir(), confirm = interactive() )
cache_dir |
Length-one character path to a package-owned cache directory. |
confirm |
A length-one logical. Must be |
A one-row data frame with cache_dir, removed_files, and
removed_bytes columns.
bluertopo_cache_clear(confirm = TRUE)bluertopo_cache_clear(confirm = TRUE)
Returns the configured package cache directory without creating it.
bluertopo_cache_dir()bluertopo_cache_dir()
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.
A length-one character vector containing the normalized cache path.
bluertopo_cache_dir()bluertopo_cache_dir()
Discovers selected BlueTopo tiles, downloads original GeoTIFF files and optional RAT sidecars, verifies them, and writes download manifests.
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() )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() )
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. |
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 must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a terra::SpatVector;
an sf::sf data frame or sf::sfc geometry 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(); or
a 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.
aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715) files <- bluertopo_download( aoi, path = file.path(tempdir(), "bluertopo-downloads") )aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715) files <- bluertopo_download( aoi, path = file.path(tempdir(), "bluertopo-downloads") )
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.
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 )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 )
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
|
A bluertopo_resolution S3 object containing the normalized policy
fields. Pass it to the resolution argument of bluertopo(),
bluertopo_tiles(), or bluertopo_download().
bluertopo_resolution("nearest", value = 10, tie = "finer") bluertopo_resolution("between", min_m = 4, max_m = 16)bluertopo_resolution("nearest", value = 10, tie = "finer") bluertopo_resolution("between", min_m = 4, max_m = 16)
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.
bluertopo_tile_polygons( cache_dir = bluertopo_cache_dir(), refresh = "if_stale", quiet = FALSE )bluertopo_tile_polygons( cache_dir = bluertopo_cache_dir(), refresh = "if_stale", quiet = FALSE )
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. |
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.
tile_polygons <- bluertopo_tile_polygons()tile_polygons <- bluertopo_tile_polygons()
Returns selected NOAA BlueTopo tile footprints and standardized metadata without downloading raster assets.
bluertopo_tiles( aoi, resolution = "native", coverage = "warn", min_coverage = 1, cache_dir = bluertopo_cache_dir(), refresh = "if_stale", quiet = FALSE )bluertopo_tiles( aoi, resolution = "native", coverage = "warn", min_coverage = 1, cache_dir = bluertopo_cache_dir(), refresh = "if_stale", quiet = FALSE )
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. |
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 must resolve to polygon or multipolygon geometry with a known
coordinate reference system (CRS). Accepted inputs are:
a terra::SpatVector;
an sf::sf data frame or sf::sfc geometry 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(); or
a 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.
aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715) tiles <- bluertopo_tiles(aoi)aoi <- c(xmin = -74.045, ymin = 40.675, xmax = -73.995, ymax = 40.715) tiles <- bluertopo_tiles(aoi)