Closed EmilyMarkowitz-NOAA closed 8 months ago
Hi Em,
Something similar to this is already implemented in the package by using the "pretty" method:
library(akgfmaps)
ebs_layers <- akgfmaps::get_base_layers(select.region = "ebs",
set.crs = "EPSG:3338")
sample_locations <- sf::st_as_sf(akgfmaps::YFS2017,
coords = c("LONGITUDE", "LATITUDE"),
crs = "WGS84") |>
sf::st_transform(crs = "EPSG:3338")
idw <- make_idw_stack(x = dplyr::bind_rows(akgfmaps::YFS2017,
dplyr::mutate(akgfmaps::YFS2017, YEAR = 999)),
grouping.vars = "YEAR",
out.crs = "EPSG:3338",
region = "ebs",
set.breaks = "pretty",
extrapolation.grid.type = "sf")
ggplot() +
geom_sf(data = idw$extrapolation.stack,
mapping = aes(fill = var1.pred),
color = NA) +
geom_sf(data = sample_locations) +
scale_fill_viridis_d() +
facet_wrap(~YEAR)
However, I would generally recommend avoiding automatic break selection and, [instead, set up] breaks based on information about the density distribution of the species because there really isn't a an algorithm for selecting breaks that works well for all species. The eval_plot_breaks() function is supposed to help guide the selection of breaks:
akgfmaps::eval_plot_breaks(akgfmaps::YFS2017$CPUE_KGHA, n.breaks = 5)
Oh good to know, I wasn't aware of this function. Thanks for this! Considering the parallel discussion in https://github.com/afsc-gap-products/akgfmaps/issues/40, I'll close this issue, too.
Suggestion
This is the function I use in the Bering Sea data report to set neat, rounded, set breaks for distribution plots created using the
akgfmaps
R package. I thought it could be useful to this package and to users of this package, and it would be best to add it this package. The function is below. Modify and improve as you see fit!Function
Comparison
As shown in the function example, using this package will produce:
which should be compared with the below, which is fine, but messier: