Error generating custom bathymetry shapefile
Opened this issue · 1 comments
TineNilsen commented
I would like to generate a custom bathymetry shapefile based on the GEBCO dataset. The following code worked previously, but now I get an error.
arcticCRS <- paste0("EPSG:", shapefile_list("Arctic")$crs)
bound.limits <- c(-2, 20, 55, 90)
rb <- raster_bathymetry(bathy='/GEBCO_2020.nc',
depths = c(50, 100,150, 200,250,300),
proj.out = arcticCRS,
boundary = bound.limits
)
rv <- vector_bathymetry(rb)
Error message: Error in st_as_sf.stars(bathy$raster, as_points = FALSE, merge = TRUE) :
merge=TRUE and as_points=TRUE unsupported; consider using st_contour for generating contour lines
MikkoVihtakari commented
Try making the breaks using the raster data instead. It should work better now:
library(ggOceanMaps)
#> Loading required package: ggplot2
#> ggOceanMaps: Setting data download folder to a temporary folder
#> /var/folders/9v/b70pd53x04d3jjmlrbcgp4_w0000gv/T//RtmpE1jAJM. This
#> means that any downloaded map data need to be downloaded again when you
#> restart R. To avoid this problem, change the default path to a
#> permanent folder on your computer. Add following lines to your
#> .Rprofile file: {.ggOceanMapsenv <- new.env(); .ggOceanMapsenv$datapath
#> <- 'YourCustomPath'}. You can use usethis::edit_r_profile() to edit the
#> file. '~/ggOceanMapsLargeData' would make it in a writable folder on
#> most operating systems.
options(ggOceanMaps.datapath = "~/Documents/ggOceanMapsLargeData")
breaks <- c(0,50, 100,150, 200,250,300,4000)
basemap(limits = c(3.5, 10.5, 57.7, 65.5), bathy.style = "rcb") +
binned_scale(
aesthetics = "fill",
scale_name = "stepsn",
palette = function(x) colorRampPalette(c("#F7FBFF", "#DEEBF7", "#9ECAE1", "#4292C6", "#08306B"))(length(breaks)),
limits = c(min(breaks), max(breaks)),
breaks = breaks,
show.limits = TRUE
)
#> Warning: The `scale_name` argument of `binned_scale()` is deprecated as of ggplot2
#> 3.5.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Scale for fill is already present.
#> Adding another scale for fill, which will replace the existing scale.
#> Warning: Removed 31306 rows containing missing values or values outside the scale range
#> (`geom_raster()`).
Created on 2024-08-05 with reprex v2.1.0