Skip to content

Commit

Permalink
Add GCS land crop (see 3.5.1 NEWS)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-rohan-NOAA committed Apr 10, 2024
1 parent 00c01fa commit 8060cfa
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: akgfmaps
Type: Package
Title: Alaska Groundfish and Ecosystem Survey Area Mapping
Version: 3.5.0
Version: 3.5.1
Authors@R: c(person("Sean", "Rohan", email = "[email protected]", role = c("aut", "cre")),
person("Jason", "Conner", email = "[email protected]", role = "ctb"),
person("Liz", "Dawson", role = "ctb"),
Expand All @@ -24,7 +24,7 @@ Description: This package provides tool and shapefiles to facilitate map-making
License: GPL (>=2)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Suggests:
testthat (>= 3.0.0),
knitr,
Expand Down
10 changes: 9 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
akgfmaps 3.5.1 (March 25, 2024)
akgfmaps 3.5.1 (April 10, 2024)
----------------------------------------------------------------

IMPROVEMENTS

- get_base_layers() now accepts an argument to split land
polygons into east and west when set.crs is a geographic
coordinate system. The default is to split using
split.land.at.180 = TRUE. Set this to FALSE when shifting
coordinates afterwards.

NEW FEATURES

- Added make_wkt_table(), a function that calculates areas of
Expand Down
15 changes: 15 additions & 0 deletions R/get_base_layers.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param use.survey.bathymetry Should survey bathymetry be used?
#' @param include.corners Logical. Should corner stations be returned in the survey grid? Only for the EBS.
#' @param fix.invalid.geom Should invalid geometries be corrected using st_make_valid() and st_wrap_dateline()?
#' @param split.land.at.180 Logical. If set.crs is a geographic coordinate system, should the land polygon be split at 180 degrees to prevent polygons from wrapping around the world? Default = TRUE.
#' @return A list containing sf objects land, bathymetry, survey area boundary, survey strata, survey grid (optional), a data frame of feature labels, coordinate reference system for all objects, and a suggested boundary.
#' @import sf
#' @export
Expand All @@ -14,6 +15,7 @@ get_base_layers <- function(select.region,
set.crs = "+proj=longlat +datum=NAD83",
use.survey.bathymetry = TRUE,
include.corners = NULL,
split.land.at.180 = TRUE,
fix.invalid.geom = TRUE) {

stopifnot("get_base_layers: include.corners argument must be NULL, TRUE, or FALSE." = c(is.null(include.corners) || is.logical(include.corners)))
Expand Down Expand Up @@ -441,6 +443,19 @@ get_base_layers <- function(select.region,
inpfc.strata <- akgfmaps:::fix_geometry(x = inpfc.strata)
}

# Split land polygons to fix dateline wrapping for lat/lon --------------------------------------
if(sf::st_is_longlat(akland) & split.land.at.180) {

west <- sf::st_crop(akland, xmin = -179.9995, xmax = -90, ymin = 0, ymax = 90)

east <- sf::st_crop(akland, xmin = 90, xmax = 179.9995, ymin = 0, ymax = 90)

akland <- dplyr::bind_rows(west, east)

akland <- akland[which(sf::st_geometry_type(akland$geometry) %in% c("POLYGON", "MULTIPOLYGON")), ]

}

return(list(akland = akland,
survey.area = survey.area,
survey.strata = survey.strata,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions assets/region_shapefiles/make_regional_shapefiles.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generate zip files with regional shapefiles
# Run for every new release or when shapefiles are updated
library(akgfmaps)

todays_date <- gsub(x = Sys.Date(), pattern = "-", replacement = "")

Expand Down
3 changes: 3 additions & 0 deletions man/get_base_layers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8060cfa

Please sign in to comment.