Skip to content

BigelowLab/cofbb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cofbb

This R package serves the spatial bounding box and polygon definitions we use in the Record Lab.

Requirements

Suggested

Installation

remotes::install_github("BigelowLab/cofbb")

Usage

Retrieve a table of all known bounding boxes.

cofbb::get_table()
## # A tibble: 20 × 6
##    name                xmin  xmax  ymin  ymax longname                       
##    <chr>              <dbl> <dbl> <dbl> <dbl> <chr>                          
##  1 maine              -71.1 -67    43    47.5 State of Maine                 
##  2 gom                -72   -63    39    46   Gulf of Maine                  
##  3 gom_carcharodon    -74.9 -63    38.8  46   GoM for White Sharks           
##  4 nwa_orig           -77   -51.5  37.9  56.7 Northwest Atlantic             
##  5 nwa                -77   -42.5  36.5  56.7 Northwest Atlantic 2           
##  6 nwa2               -77   -42.5  36.5  56.7 Northwest Atlantic 2           
##  7 chfc               -77   -42.5  35    56.7 Cape Hatteras to Flemish Cap   
##  8 neac               -74   -59.8  41    48.2 New England and Atlantic Canada
##  9 liac               -74   -59.8  37.9  48.2 Long Island and Atlantic Canada
## 10 gosl               -67   -56.5  44.4  50.5 Gulf of St. Lawrence           
## 11 world             -180   180   -90    90   World                          
## 12 world360             0   360   -90    90   World 360                      
## 13 njgb               -74.9 -66    38.8  42.6 New Jersey to Georges Bank     
## 14 nefsc_carcharodon  -74.9 -65    38.8  46   NEFSC White Shark              
## 15 cape_cod           -69.2 -70.9  41.4  42.2 Cape Cod                       
## 16 cold_blob          -30   -15    42    60   North Atalantic Cold Blob      
## 17 warm_spot          -74   -58    36    42   Warm Spot                      
## 18 nh                -180     0   180    90   Northern Hemisphere            
## 19 sh                -180   -90   180     0   Southern Hemisphere            
## 20 swa                  0    20   -35     8   Southwest Atlantic

Retrieve one or more regions by name as a table.

cofbb::get_bb(c("world", "chfc"), form = "table")
## # A tibble: 2 × 6
##   name   xmin  xmax  ymin  ymax longname                    
##   <chr> <dbl> <dbl> <dbl> <dbl> <chr>                       
## 1 chfc    -77 -42.5    35  56.7 Cape Hatteras to Flemish Cap
## 2 world  -180 180     -90  90   World

Retrieve one or more regions by name as a list of vector in [xmin, xmax, ymin, ymax] order.

cofbb::get_bb(c("world", "chfc"), form = "bb")
## $chfc
##  xmin  ymin  xmax  ymax 
## -77.0  35.0 -42.5  56.7 
## 
## $world
## xmin ymin xmax ymax 
## -180  -90  180   90

Or retrieve just one as a vector

cofbb::get_bb("gom", form = "bb")
## xmin ymin xmax ymax 
##  -72   39  -63   46

Ancillary Functions

There are also functions for making [-180, 180] <-> [0,360] longitude transformations (to_180BB(), to_360BB()), splitting bounding boxes (bb_split()) and determining if a box straddles a particular line of longitude (bb_straddles()).

You can also retrieve bounding boxes as a data frame of one or more sf POLYGON objects.

x <- cofbb::get_bb(c("gosl", "gom", "chfc"), form = "sf")
x
## Simple feature collection with 3 features and 1 field
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -77 ymin: 35 xmax: -42.5 ymax: 56.7
## Geodetic CRS:  WGS 84
##   name                           geom
## 1 gosl POLYGON ((-67 44.4, -56.5 4...
## 2  gom POLYGON ((-72 39, -63 39, -...
## 3 chfc POLYGON ((-77 35, -42.5 35,...

If you have leaflet installed you can draw a pretty map (otherwise a boring map is drawn.)

plot_bb(x)

leaflet

leaflet

Updating

Pre-packaged data are stored in locally in /mnt/s1/projects/ecocast/coredata/cofbb/bbox_lonlat.csv and are then absorbed into the package. Updates to the package can happen at any time. First, edit the source data file to suit your needs. Then run the following…

$ Rscript /mnt/ecocast/corecode/R/cofbb/scripts/update_package.R

If you do the above with sudo privileges then it will be installed into the system-wide R package library, otherwise it will be installed into the user R package library.

Polygons

We now include some polygons used for various projects.

cofbb::list_polygons()
## [1] "ojohnson_2025.gpkg"
cofbb::read_polygons("ojohnson_2025")
## Simple feature collection with 9 features and 1 field
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -80 ymin: 34 xmax: -43.87312 ymax: 59
## Geodetic CRS:  WGS 84
## # A tibble: 9 × 2
##   id                                                                        geom
##   <chr>                                                       <MULTIPOLYGON [°]>
## 1 Lower MAB (((-80 34, -79.93322 34, -79.86644 34, -79.79967 34, -79.73289 34, …
## 2 GoM       (((-70.5174 41.68678, -70.23092 41.68678, -69.97943 41.73917, -69.9…
## 3 WSS       (((-62.82787 45.38058, -62.85399 45.36388, -62.85399 45.38089, -62.…
## 4 ESS       (((-56.56925 44.62834, -56.62771 44.62834, -56.70439 44.59, -56.73 …
## 5 swGSL     (((-60.00542 47.08575, -60.2614 46.93115, -60.74507 46.607, -60.822…
## 6 nGSL      (((-55.727 52.247, -55.28 52.02, -55.427 51.645, -56.093 51.513, -5…
## 7 NLS       (((-59.66684 47.27857, -57.09625 48.74323, -56.77879 51.05262, -56.…
## 8 GB        (((-65.47818 42.1372, -65.48543 42.14844, -65.51345 42.16097, -65.5…
## 9 Upper MAB (((-68.56864 40.08907, -68.77559 40.3575, -69.01623 40.64398, -69.0…

NOTE on nwa and nwa2

As of 2025-03-10 nwa has been renamed nwa_orig but it is essentially deprecated. nwa and nwa2 now point to the same bounding box which modified from nwa_orig to accommodate Flemish Cap. The point is, calling for nwa and nwa2 is now the same thing.

About

Center for Ocean Forecasting spatial bounding boxes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages