Skip to content

Commit

Permalink
Merge pull request #55 from emlab-ucsb/dev-bathy-densify
Browse files Browse the repository at this point in the history
Dev bathy densify
  • Loading branch information
jflowernet authored Jan 14, 2025
2 parents 2813be8 + e3463da commit 3ba050f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: oceandatr
Type: Package
Title: Ocean Data Access
Version: 0.2.1
Version: 0.2.1.1
Authors@R: person(given = "Jason", family = "Flower", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-6731-8182"))
Description: For retrieving and gridding ocean related data.
License: GPL (>= 3) + file LICENSE
Expand Down
6 changes: 5 additions & 1 deletion R/get_bathymetry.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ get_bathymetry <- function(spatial_grid = NULL, raw = FALSE, classify_bathymetry

area_polygon_for_cropping <- polygon_in_4326(spatial_grid)

antimeridian <- check_antimeridian(area_polygon_for_cropping, sf::st_crs(4326))
antimeridian <- area_polygon_for_cropping %>%
terra::vect() %>%
terra::densify(interval = 1e4) %>%
sf::st_as_sf() %>%
check_antimeridian(sf::st_crs(4326))

if(is.null(bathymetry_data_filepath)){
bathymetry <- get_etopo_bathymetry(area_polygon_for_cropping, resolution = resolution, keep = keep, path = path, download_timeout = download_timeout) %>%
Expand Down
4 changes: 3 additions & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,7 @@ get_kiribati_grid <- function(resolution = 50, output = "raster") {
get_grid(boundary = get_boundary(name = "Kiribati", country_type = "sovereign"),
crs = '+proj=laea +lon_0=-159.609375 +lat_0=0 +datum=WGS84 +units=m +no_defs',
resolution = resolution*1e3,
output = output)
output = output,
touches = TRUE
)
}
2 changes: 1 addition & 1 deletion oceandatr.Rproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Version: 1.0
ProjectId: 07412d5b-db37-48bb-9e7b-231d1cd8b6e7
ProjectId: 44d5a628-6d1f-4926-acb1-e59e7a6de20d

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-get_bathymetry.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ test_that("returns gridded Bermuda depth classes", {
expect_s4_class(get_bathymetry(spatial_grid = get_bermuda_grid()), class = "SpatRaster")
})

# test_that("returns Kiribati gridded depth classes", {
# expect_s4_class(get_bathymetry(spatial_grid = kiribati_grid()),
# class = "SpatRaster")
# })
test_that("returns Kiribati gridded depth classes", {
expect_s4_class(get_bathymetry(spatial_grid = get_kiribati_grid()),
class = "SpatRaster")
})

test_that("returns gridded Bermuda depth classes", {
expect_s3_class(get_bathymetry(spatial_grid = get_bermuda_grid(output = "sf_hex")), class = "sf")
Expand Down

0 comments on commit 3ba050f

Please sign in to comment.