diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_ai_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_ai_20240520.zip new file mode 100644 index 0000000..49225b8 Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_ai_20240520.zip differ diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_chukchi_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_chukchi_20240520.zip new file mode 100644 index 0000000..4307b58 Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_chukchi_20240520.zip differ diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_ebsslope_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_ebsslope_20240520.zip new file mode 100644 index 0000000..37157ba Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_ebsslope_20240520.zip differ diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_goa_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_goa_20240520.zip new file mode 100644 index 0000000..25787e6 Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_goa_20240520.zip differ diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_nbs_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_nbs_20240520.zip new file mode 100644 index 0000000..17bb4e7 Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_nbs_20240520.zip differ diff --git a/assets/bts_geopackages/akgfmaps_shapefiles_sebs_20240520.zip b/assets/bts_geopackages/akgfmaps_shapefiles_sebs_20240520.zip new file mode 100644 index 0000000..0baf72a Binary files /dev/null and b/assets/bts_geopackages/akgfmaps_shapefiles_sebs_20240520.zip differ diff --git a/assets/demo/akgfmaps_SCRUG_20250122/ex2_get_layers.R b/assets/demo/akgfmaps_SCRUG_20250122/ex2_get_layers.R index a82b313..8dc4050 100644 --- a/assets/demo/akgfmaps_SCRUG_20250122/ex2_get_layers.R +++ b/assets/demo/akgfmaps_SCRUG_20250122/ex2_get_layers.R @@ -14,7 +14,7 @@ library(akgfmaps) # Get layers for one survey region ebs_layers <- akgfmaps::get_base_layers( - select.region = "sebs", # EBS shelf bottom traw survey regions + select.region = "sebs", # EBS shelf bottom trawl survey regions set.crs = "EPSG:3338", # Coordinate reference system, in this case Alaska Albers Equal Area high.resolution.coast = FALSE, # Set to TRUE when coast is used for analyses, e.g. raster masking design.year = NULL # Return the most recent/current survey design @@ -92,17 +92,17 @@ goa_1984_2025_strata <- rbind( # Plot 1984 and 2025 survey strata for the WGOA ggplot() + - geom_sf(data = goa_1984$akland) + + geom_sf(data = goa_1984_layers$akland) + geom_sf(data = goa_1984_2025_strata, mapping = aes(color = factor(DESIGN_YEAR)), fill = NA, alpha = 0.5) + scale_color_manual(name = "Design year", values = c("red", "black")) + - scale_x_continuous(limits = goa_1984$plot.boundary$x, - breaks = goa_1984$lon.breaks) + - scale_y_continuous(limits = goa_1984$plot.boundary$y, - breaks = goa_1984$lat.breaks) + + scale_x_continuous(limits = goa_1984_layers$plot.boundary$x, + breaks = goa_1984_layers$lon.breaks) + + scale_y_continuous(limits = goa_1984_layers$plot.boundary$y, + breaks = goa_1984_layers$lat.breaks) + theme_bw() goa_1984_2025_grid <- rbind( @@ -112,17 +112,17 @@ goa_1984_2025_grid <- rbind( # Plot 1984 and 2025 survey grid for the WGOA ggplot() + - geom_sf(data = goa_1984$akland) + + geom_sf(data = goa_1984_layers$akland) + geom_sf(data = goa_1984_2025_grid, mapping = aes(color = factor(DESIGN_YEAR)), fill = NA, alpha = 0.5) + scale_color_manual(name = "Design year", values = c("red", "black")) + - scale_x_continuous(limits = goa_1984$plot.boundary$x, - breaks = goa_1984$lon.breaks) + - scale_y_continuous(limits = goa_1984$plot.boundary$y, - breaks = goa_1984$lat.breaks) + + scale_x_continuous(limits = goa_1984_layers$plot.boundary$x, + breaks = goa_1984_layers$lon.breaks) + + scale_y_continuous(limits = goa_1984_layers$plot.boundary$y, + breaks = goa_1984_layers$lat.breaks) + theme_bw() # EBS shelf survey with corner stations for the 2023 survey diff --git a/assets/demo/akgfmaps_SCRUG_20250122/ex3_make_idw_map.R b/assets/demo/akgfmaps_SCRUG_20250122/ex3_make_idw_map.R index af2f0fa..f69d550 100644 --- a/assets/demo/akgfmaps_SCRUG_20250122/ex3_make_idw_map.R +++ b/assets/demo/akgfmaps_SCRUG_20250122/ex3_make_idw_map.R @@ -27,6 +27,8 @@ noodles_sf <- akgfmaps::NOODLES |> dplyr::rename(STATION = STATIONID) |> dplyr::mutate(Present = CPUE_KGHA > 0) # Plot presence/absence +nbs_layers <- get_base_layers(select.region = "nbs", set.crs = "EPSG:3338") + # spatially join survey grid polygons to noodle CPUE points data noodles_grid <- sf::st_join(nbs_layers$survey.grid, noodles_sf) diff --git a/assets/demo/akgfmaps_SCRUG_20250122/ex4_geopackages.R b/assets/demo/akgfmaps_SCRUG_20250122/ex4_geopackages.R new file mode 100644 index 0000000..5e32252 --- /dev/null +++ b/assets/demo/akgfmaps_SCRUG_20250122/ex4_geopackages.R @@ -0,0 +1,78 @@ +# Example: Access data directly from a geopackage +# SCRUG, akgfmaps, January 22, 2025 +# Created by Sean Rohan (GitHub: sean-rohan-noaa) + +# akgfmaps installs layer files locally +# Layers used to include a variety of formats; starting with akgfmaps v4, layers will be included in +# geopackage (.gpkg) files. +list.files(system.file("extdata", package = "akgfmaps"), + full.names = TRUE) + +# Loading layers directly from built-in Geopackage +# Geopackages are an open, standards-based, platform-independent format for storing geospatial data. +# They are based on SQLite, can store multiple layers and data types in one file. + +library(akgfmaps) +library(dplyr) + +# Filepath to geopackage with AFSC bottom trawl survey layers +gpkg_fpath <- system.file("extdata", "afsc_bottom_trawl_surveys.gpkg", package = "akgfmaps") + +# Inpsect the layers at the dsn (data source name). +# There are four layers in individual tables (called 'layers' in sf) +sf::st_layers(dsn = gpkg_fpath) + +# Load all of of the features from the survey_area layer +survey_areas <- sf::st_read(dsn = gpkg_fpath, + layer = "survey_area") + +survey_areas + +# Plot the survey areas +ggplot() + + geom_sf(data = survey_areas, + mapping = aes(color = SURVEY_NAME), + fill = NA) + + facet_wrap(~DESIGN_YEAR) + + theme(legend.position = "bottom") + +# Filter to retreive the NBS survey area +nbs_area <- dplyr::filter(survey_areas, SURVEY_DEFINITION_ID == 143) + +ggplot() + + geom_sf(data = nbs_area, + mapping = aes(color = SURVEY_NAME)) + + facet_wrap(~DESIGN_YEAR) + + theme(legend.position = "bottom") + +# Alternatively, we can retrieve features from the geopackage using a SQLite query. +# In this case, retrieve GOA stratum polygons for the 1984 and 2025 design years. +goa_strata <- sf::st_read(dsn = gpkg_fpath, + query = + "SELECT + AREA_TYPE, + SURVEY_DEFINITION_ID, + DESIGN_YEAR, + AREA_ID AS STRATUM, + AREA_M2, + GEOM + FROM SURVEY_STRATA + WHERE SURVEY_DEFINITION_ID = 47" + ) + +head(goa_strata) +table(goa_strata$DESIGN_YEAR) + +# Plotting the 1984 and 2025 GOA survey strata +ggplot() + + geom_sf(data = goa_strata, + mapping = aes(fill = factor(STRATUM)), + color = NA) + + scale_fill_viridis_d(option = "H") + + facet_wrap(~DESIGN_YEAR, nrow = 2) + + theme(legend.position = "none", + axis.title = element_blank()) + + +# Land layers +sf::st_layers(dsn = system.file("extdata", "land_layers.gpkg", package = "akgfmaps")) diff --git a/assets/demo/akgfmaps_SCRUG_20250122/ex5_get_layers_old_version.R b/assets/demo/akgfmaps_SCRUG_20250122/ex5_get_layers_old_version.R new file mode 100644 index 0000000..6e24903 --- /dev/null +++ b/assets/demo/akgfmaps_SCRUG_20250122/ex5_get_layers_old_version.R @@ -0,0 +1,75 @@ +# Example: Using the old get_base_layers() function +# SCRUG, akgfmaps, January 22, 2025 +# Created by Sean Rohan (GitHub: sean-rohan-noaa) + +# Through the end of 2025, an option will be provided to use the old interface and layers using +# get_base_layers_v3(). The function is limited to the functionality and layers that were avaialble +# in akgfmaps v 3.6.2 +# +# The old version has the following limitations: +# - No access to design years (e.g., the most recent GOA BT survey stratum shapefile will be 1984) +# - Cannot select multiple regions at the same time +# - Field names differ among shapefiles +# - No correspondence with GAP_PRODUCTS +# - Access to longline + +# Recommendation: Don't use this version unless you can't replace with the new version due to time +# and reliance on fields in specific shapefiles. + +library(akgfmaps) + +# Arguments differ between function versions +?get_base_layers +?get_base_layers_v3 + +# Retrieve and plot GOA and EBS/NBS strata +goa_1984_v3 <- akgfmaps::get_base_layers_v3( + select.region = "goa", + set.crs = "EPSG:3338", + high.resolution.coast = FALSE +) + +ebs_nbs_2024_v3 <- akgfmaps::get_base_layers_v3( + select.region = "ebs", + set.crs = "EPSG:3338", + high.resolution.coast = FALSE +) + +ggplot() + + geom_sf(data = goa_1984_v3$akland) + + geom_sf(data = goa_1984_v3$survey.strata, + mapping = aes( + fill = factor(STRATUM) + ) + ) + + scale_x_continuous(limits = goa_1984_v3$plot.boundary$x, + breaks = goa_1984_v3$lon.breaks) + + scale_y_continuous(limits = goa_1984_v3$plot.boundary$y, + breaks = goa_1984_v3$lat.breaks) + + theme_bw() + + scale_fill_viridis_d(option = "H") + + theme(legend.position = "none") + +ggplot() + + geom_sf(data = ebs_nbs_2024_v3$akland) + + geom_sf(data = ebs_nbs_2024_v3$survey.strata, + mapping = aes( + fill = factor(Stratum) + ) + ) + + scale_x_continuous(limits = ebs_nbs_2024_v3$plot.boundary$x, + breaks = ebs_nbs_2024_v3$lon.breaks) + + scale_y_continuous(limits = ebs_nbs_2024_v3$plot.boundary$y, + breaks = ebs_nbs_2024_v3$lat.breaks) + + scale_fill_viridis_d(option = "H") + + theme_bw() + + theme(legend.position = "none") + +# Note that the field names do not match within or between regions. +head(goa_1984_v3$survey.area) +head(goa_1984_v3$survey.strata) +head(goa_1984_v3$survey.grid) + +head(ebs_nbs_2024_v3$survey.area) +head(ebs_nbs_2024_v3$survey.strata) +head(ebs_nbs_2024_v3$survey.grid) diff --git a/assets/regional_shapefiles/akgfmaps_ebs_20231219.zip b/assets/regional_shapefiles/akgfmaps_ebs_20231219.zip new file mode 100644 index 0000000..24a15c0 Binary files /dev/null and b/assets/regional_shapefiles/akgfmaps_ebs_20231219.zip differ