Skip to content

Commit

Permalink
AI Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bethanyriggle committed Nov 21, 2023
1 parent fde1bcf commit 8b6efb5
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions make_layers_ai.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
library(navmaps)
region <- "ai" # Options are sebs, nbs, ai, goa


# 2. Load shapefiles using the akgfmaps package
map_layers <- akgfmaps::get_base_layers(select.region = region)
channel <- get_connected(schema = "AFSC")
Expand Down Expand Up @@ -40,7 +41,7 @@ for(ii in 1:length(software_types)) {
sf_to_nav_file(
x = survey_grid,
geometry = "LINESTRING",
file = here::here("output", region, "navigation", paste0(region, "_station_grid.", FILE_TYPE_POLYGON)),
file = here::here("output", region, "navigation", SOFTWARE, paste0(region, "_station_grid.", FILE_TYPE_POLYGON)),
name_col = "ID",
description_col = "STRATUM",
color_col = "color",
Expand All @@ -54,7 +55,7 @@ for(ii in 1:length(software_types)) {

sf_to_nav_file(
x = grid_centers,
file = here::here("output", region, "navigation", paste0(region, "_marks.", FILE_TYPE_POINT)),
file = here::here("output", region, "navigation", SOFTWARE, paste0(region, "_marks.", FILE_TYPE_POINT)),
name_col = "ID",
description_col = "ID",
color_col = "color",
Expand Down Expand Up @@ -85,7 +86,7 @@ for(ii in 1:length(software_types)) {

sf_to_nav_file(
x = strata,
file = here::here("output", region, "navigation", paste0(region, "_survey_strata.", FILE_TYPE_POLYGON)),
file = here::here("output", region, "navigation", SOFTWARE, paste0(region, "_survey_strata.", FILE_TYPE_POLYGON)),
name_col = "name",
description_col = "STRATUM",
color_col = "color",
Expand All @@ -100,7 +101,7 @@ for(ii in 1:length(software_types)) {

sf_to_nav_file(
x = ssl,
file = here::here("output", region, "navigation", paste0(region, "_ssl_no_transit.", FILE_TYPE_POLYGON)),
file = here::here("output", region, "navigation", SOFTWARE, paste0(region, "_ssl_no_transit.", FILE_TYPE_POLYGON)),
name_col = "Name",
description_col = "Name",
color_col = "color",
Expand All @@ -109,13 +110,15 @@ for(ii in 1:length(software_types)) {
)

# 10. Sea Otter Critical Habitat
otters <- sf::st_read(here::here("data", "otters", "SeaOtterFinalCH_Project.shp"))
otters <- sf::st_read(here::here("data", "otters", "SeaOtterFinalCH_Project.shp")) |>
sf::st_make_valid() |> dplyr::mutate(CH_Unit=NA)

otters$name <- "Otter Habitat"
otters$color <- navmaps_pal(values = "cyan", software_format = SOFTWARE, file_type = FILE_TYPE_POLYGON)
otters$fill <- navmaps_pal(values = "cyan", software_format = SOFTWARE, file_type = FILE_TYPE_POLYGON)
otters$color <- navmaps_pal(values = "red", software_format = SOFTWARE, file_type = FILE_TYPE_POLYGON)
otters$fill <- 0

sf_to_nav_file(x = otters,
file = here::here("output", region, "navigation", paste0("otter_habitat.", FILE_TYPE_POLYGON)),
file = here::here("output", region, "navigation",SOFTWARE, paste0("otter_habitat.", FILE_TYPE_POLYGON)),
name_col = "name",
description_col = "CH_Unit",
color_col = "color",
Expand All @@ -130,23 +133,35 @@ for(ii in 1:length(software_types)) {
nprw$fill <- 0

sf_to_nav_file(x = nprw,
file = here::here("output", region, "navigation", paste0("NPRW_Critical_Habitat.", FILE_TYPE_POLYGON)),
file = here::here("output", region, "navigation", SOFTWARE, paste0("NPRW_Critical_Habitat.", FILE_TYPE_POLYGON)),
name_col = "name",
description_col = "description",
color_col = "color",
fill_col = "fill",
software_format = SOFTWARE)

# 12. Buoys
buoys <- read.csv(file = here::here("data", "buoys", "Buoys_2022.csv")) |>
sf::st_as_sf(coords = c("Longitude", "Latitude"), crs = "EPSG:4326")
buoys$shape <- navmaps_sym_pal(values = "warning", software_format = "globe", file_type = FILE_TYPE_POINT)
buoys$color <- navmaps_pal(values = "darkorange", software_format = SOFTWARE, file_type = FILE_TYPE_POINT)
buoys$description <- paste0("Top float: ", buoys$TOP.FLOAT.DEPTH, "; Depth: ", buoys$WATER.DEPTH)
buoys <- readxl::read_xlsx(path = here::here("data", "buoys", "Buoys_2023_11_21.xlsx")) |>
dplyr::mutate(LONGITUDE = dms_string_to_dd(POSITION)[,1],
LATITUDE = dms_string_to_dd(POSITION)[,2]) |>
sf::st_as_sf(coords = c("LONGITUDE", "LATITUDE"), crs = "EPSG:4326")

ggplot() +
geom_sf(data=buoys) #+
# geom_sf_text(data=buoys, mapping=aes(label=`TYPE/NAME`))
buoys$shape <- navmaps_sym_pal(values = "warning",
software_format = SOFTWARE,
file_type = FILE_TYPE_POINT)
buoys$color <- navmaps_pal(values = "darkorange",
software_format = SOFTWARE,
file_type = FILE_TYPE_POINT)
buoys$description <- paste0("Top float: ", buoys$`TOP FLOAT DEPTH`, "; Depth: ", buoys$`WATER DEPTH`)

sf::st_write(buoys, dsn = here::here("output", region, "shapefiles", paste0("buoys_2023_11_21.shp")))

sf_to_nav_file(x = buoys,
file = here::here("output", region, "navigation", paste0("buoys_2022.", FILE_TYPE_POINT)),
name_col = "TYPE.NAME",
file = here::here("output", region, "navigation", SOFTWARE, paste0("buoys_2023_11_21.", FILE_TYPE_POINT)),
name_col = "TYPE/NAME",
description_col = "description",
color_col = "color",
shape_col = "shape",
Expand Down Expand Up @@ -174,4 +189,4 @@ for(ii in 1:length(software_types)) {

# 14. Special projects

}
}

0 comments on commit 8b6efb5

Please sign in to comment.