Package 'picMaps'

Title: Mapping Utilities for The Pacific Ocean
Description: This package provides objects and functions for making plots and maps easier to create in the Pacific Ocean.
Authors: Devin S. Johnson
Maintainer: Devin S. Johnson <[email protected]>
License: CC0
Version: 0.1.9032
Built: 2026-09-24 00:01:59 UTC
Source: https://github.com/PIFSC-Protected-Species-Division/picMaps

Help Index


Functions To Aid Mapping of PIFSC Data

Description

This package is a collection of functions that helps gather spatial data for creating maps in the Pacific Ocean.

Note

This software package is developed and maintained by scientists at the NOAA Fisheries Pacific Islands Fisheries Science Center and should be considered a fundamental research communication. The recommendations and conclusions presented here are those of the authors and this software should not be construed as official communication by NMFS, NOAA, or the U.S. Dept. of Commerce. In addition, reference to trade names does not imply endorsement by the National Marine Fisheries Service, NOAA. While the best efforts have been made to insure the highest quality, tools such as this are under constant development and are subject to change.

Author(s)

Devin S. Johnson <[email protected]> (Maintainer)


All Pacific Island US EEZ

Description

All Pacific Island US EEZ

Usage

all_eez()

American Samoa US EEZ boundary polygon

Description

American Samoa US EEZ boundary polygon

Usage

am_samoa_eez()

Bhattacharyya distance for 2 raster probability densities

Description

Bhattacharyya distance for 2 raster probability densities

Usage

bc_raster(r, s)

Arguments

r

SpatRaster object

s

SpatRaster object

Details

Computes Bhattacharyya distance for 2 raster UDs.The 2 rasters are first normalized to sum to 1.


Central Pacific Boundary for Pelagic False Killer Whales

Description

Central Pacific Boundary for Pelagic False Killer Whales

Usage

cenpac()

Download ETOPO 2022 Bathymetery data

Description

Downloads bathymetery data for map making.

Usage

etopo_download(resolution = 60, force = FALSE)

Arguments

resolution

numeric resolution in arcsecs (one of 30, or 60). Defaults to 60 arcsecs.

force

Logical. If data has previously been downloaded, it will force a new download and update of the OSM data.

Author(s)

Devin S. Johnson

References

https://osmdata.openstreetmap.de/data/land-polygons.html


Extract Bathymetry Data From Downloaded ETOPO 2022 data.

Description

The majority of this function is taken from the topotools package here: https://github.com/BigelowLab/topotools/tree/main. It was modified to work within the 'picMaps' package.

Usage

etopo_rast(x, resolution = 60, ...)

Arguments

x

an sf spatial object that will define the extent of the bathymetry raster.

resolution

Resolution of the ETOPO bathymetry raster, either 60 or 30 arc-seconds. Defaults to resolution = 60.

...

Addtional arguments passed to terra::project.

References

  • NOAA National Centers for Environmental Information. 2022: ETOPO 2022 15 Arc-Second Global Relief Model. NOAA National Centers for Environmental Information. DOI: 10.25921/fd45-gt74. Accessed 2023-03-17.

  • https://github.com/BigelowLab/topotools/tree/main


Download Copernicus Marine Service physical oceanography data (2d variables)

Description

Download Copernicus Marine Service physical oceanography data (2d variables)

Usage

fetch_cms_phys_2d(
  region,
  variable,
  layer,
  timerange,
  return_type = "raster",
  progress = FALSE,
  asset = "ARCO",
  username = NULL,
  password = NULL
)

Arguments

region

An 'sf' or 'bbox' object. The bounding box will be used as the bounds for CMS data subsetting and download

variable

Variables from the GLOBAL_MULTIYEAR_PHY_001_030 product for download. Must be any subset of 'c("thetao","so","uo","vo")' any other variables will be ignored.

layer

One of '"daily"' or '"monthly"' for either temporal resolution.

timerange

A 2 vector of start and end dates. Both must be POSIX.

return_type

One of '"stars"' or '"raster"'. A 'stars' object is the default.

progress

Output process of download.

asset

See '?CopernicusMarine::cms_download_subset'

username

Copernicus Marine Service account username, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_username'

password

Copernicus Marine Service password, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_password'

Author(s)

Devin S. Johnson


Download Copernicus Marine Service physical oceanography data (3d variables)

Description

Download Copernicus Marine Service physical oceanography data (3d variables)

Usage

fetch_cms_phys_3d(
  region,
  variable,
  layer,
  timerange,
  verticalrange = 0,
  return_type = "raster",
  progress = FALSE,
  asset = "ARCO",
  username = NULL,
  password = NULL
)

Arguments

region

An 'sf' or 'bbox' object. The bounding box will be used as the bounds for CMS data subsetting and download

variable

Variables from the GLOBAL_MULTIYEAR_PHY_001_030 product for download. Must be any subset of 'c("thetao","so","uo","vo")' any other variables will be ignored.

layer

One of '"daily"' or '"monthly"' for either temporal resolution.

timerange

A 2 vector of start and end dates. Both must be POSIX.

verticalrange

Range of depth values to download, e.g., 'c(0,-100)' will download all CMS depth layers between 0-100m. Default is '0' for surface layer.

return_type

One of '"stars"' or '"raster"'. A 'stars' object is the default.

progress

Output process of download.

asset

See '?CopernicusMarine::cms_download_subset'

username

Copernicus Marine Service account username, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_username'

password

Copernicus Marine Service password, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_password'

Author(s)

Devin S. Johnson


Download Copernicus Marine Service physical oceanography data (surface values)

Description

Download Copernicus Marine Service physical oceanography data (surface values)

Usage

fetch_cms_phys_surface(
  region,
  variable,
  layer,
  timerange,
  return_type = "raster",
  progress = FALSE,
  asset = "ARCO",
  username = NULL,
  password = NULL
)

Arguments

region

An 'sf' or 'bbox' object. The bounding box will be used as the bounds for CMS data subsetting and download

variable

Variables from the GLOBAL_MULTIYEAR_PHY_001_030 product for download.

layer

One of '"daily"' or '"monthly"' for either temporal resolution.

timerange

A 2 vector of start and end dates. Both must be POSIX.

return_type

One of '"stars"' or '"raster"'. A 'stars' object is the default.

progress

Output process of download.

asset

See '?CopernicusMarine::cms_download_subset'

username

Copernicus Marine Service account username, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_username'

password

Copernicus Marine Service password, see '?CopernicusMarine::cms_download_subset' and '?CopernicusMarine::cms_get_password'

Author(s)

Devin S. Johnson


Show picMaps Data Storage Directory

Description

This function provides the location where 'picMaps' is storing and retrieving spatial data.

Usage

get_data_loc()

Find gradient field of a elevation raster

Description

Find gradient field of a elevation raster

Usage

get_grad(r, scale = TRUE)

Arguments

r

SpatRaster object

scale

Logical, Should the gradient be scaled by resolution of the coordinates. Defaults to 'scale = TRUE'


Coast polygons for Main Hawaiian Islands

Description

Coast polygons for Main Hawaiian Islands

Usage

hawaii_coast(keep = 0.5, union = TRUE, crs = 4326)

Arguments

keep

see osm_coast

union

see osm_coast

crs

A coordinate system object, See st_transform. Defaults to ESPG = 4326 with 0-360 longitude values.


Hawaiian Island EEZ boundary polygon

Description

Hawaiian Island EEZ boundary polygon

Usage

hawaii_eez()

Calculate cellsize value for hexagon grid

Description

Calculates the appropriate cellsize argument for making a hexagon grid with st_make_grid.

Usage

hex_size(area = NULL, radius = NULL, sep = NULL)

Arguments

area

A value (m^2) for the resulting area of a full hexagon cell

radius

The value for the distance (m) from the centroids to the edge of full hexagon cells.

sep

The distance (m) between centoids of the hexagon grid.

Author(s)

Devin S. Johnson

References

See https://github.com/r-spatial/sf/issues/1505


Import benthic habitat data for the Main Hawaiian Islands

Description

Import benthic habitat data for the Main Hawaiian Islands

Usage

hi_benthic_habitat()

HI Official State Coastline

Description

HI Official State Coastline

Usage

hi_coast_state()

Compile full layer of Main Hawaiian Island watersheds

Description

Compile full layer of Main Hawaiian Island watersheds

Usage

hi_full_watersheds()

Watershed zones out to 3mi

Description

Watershed zones out to 3mi

Usage

hi_ridge_to_reef()

Watersheds

Description

Watersheds

Usage

hi_watersheds(type = "DAR")

Arguments

type

DAR version ('type="DAR"'; default) or 'type="regular"'.


Howland and Baker Islands US EEZ boundary polygon

Description

Howland and Baker Islands US EEZ boundary polygon

Usage

howland_baker_eez()

Jarvis Islands US EEZ boundary polygon

Description

Jarvis Islands US EEZ boundary polygon

Usage

jarvis_eez()

Johnston Atoll US EEZ boundary polygon

Description

Johnston Atoll US EEZ boundary polygon

Usage

johnston_eez()

Lalo Islands

Description

Lalo Islands

Usage

lalo()

Main Hawaiian Islands Longline Exclusion Zone

Description

Main Hawaiian Islands Longline Exclusion Zone

Usage

longline_exclusion()

Coast polygons for the Mariana Islands

Description

Coast polygons for the Mariana Islands

Usage

mariana_coast(keep = 0.5, union = TRUE, crs = 4326)

Arguments

keep

see osm_coast

union

see osm_coast

crs

A coordinate system object, See st_transform. Defaults to ESPG = 4326 with 0-360 longitude values


Mariana Islands US EEZ boundary polygon

Description

Mariana Islands US EEZ boundary polygon

Usage

mariana_eez()

Main Hawaiian Islands Region Boundary

Description

Main Hawaiian Islands Region Boundary

Usage

mhi_region()

NW Hawaiian Islands polygons

Description

NW Hawaiian Islands polygons

Usage

nwhi()

Oahu roads

Description

Oahu roads

Usage

oahu_roads()

Get A Coastline sf Polygon Object For Plotting and Mapping

Description

Uses downloaded OSM data for constructing an sf polygon coastline data object. Prior to using this function you must run osm_download.

Usage

osm_coast(x, keep = 0.2, union = FALSE)

Arguments

x

An sf spatial object. The coastline will be cropped to the bounding box.

keep

The amount of data retained after simplification with ms_simplify

union

Logical. Should the returned object be returned as a single sf MULTIPOLYGON object

Author(s)

Josh M. London and Devin S. Johnson


Download Open Street Map Coastline Shapefile from Daylight Map Distribution

Description

Downloads OSM data for plotting telemetry data and use distributions.

Usage

osm_download(force = FALSE, clean_shp = TRUE)

Arguments

force

Logical. If data has previously been downloaded, it will force a new download and update of the OSM data.

clean_shp

Logical. If 'TRUE' the original shape file will be deleted and only the '.gpkg' file will be retained.

Author(s)

Devin S. Johnson and Josh M. London

References

https://osmdata.openstreetmap.de/data/land-polygons.html


Download Open Street Map Coastline Shapefile from Daylight Map Distribution

Description

Downloads OSM data for plotting telemetry data and use distributions.

Usage

osm_install(zip_file, force = FALSE, clean_shp = TRUE)

Arguments

zip_file

path to the OSM data .zip file 'land-polygons-complete-4326.zip'. If left unspecified, the user will see a directory browser to navigate to it. See the url in the references to download it by hand. Also, see 'osm_download' to download and install it.

force

Logical. If data has previously been downloaded or installed, it will force a new install and update of the OSM data.

clean_shp

Logical. If 'TRUE' the original shape file will be deleted and only the '.gpkg' file will be retained.

Author(s)

Devin S. Johnson and Josh M. London

References

Get information here: https://osmdata.openstreetmap.de/data/land-polygons.html and download with this link https://osmdata.openstreetmap.de/download/land-polygons-complete-4326.zip


Palmyra Kingman US EEZ boundary polygon

Description

Palmyra Kingman US EEZ boundary polygon

Usage

palmyra_kingman_eez()

Papahānaumokuākea boundary polygon

Description

Papahānaumokuākea boundary polygon

Usage

papahanaumokuakea()

Pelagic False Killer Whale Management Area Polygon

Description

Pelagic False Killer Whale Management Area Polygon

Usage

pfkw_mgmt()

Fill raster holes and NAs with local interpolation

Description

Fill raster holes and NAs with local interpolation

Usage

raster_fill(r)

Arguments

r

SpatRaster object

Details

Uses focal means to infill holes and NAs


Z transform a raster

Description

Z transform a raster

Usage

raster_z(r)

Arguments

r

A spatRaster object from the terra package


Set Data Storage Directory

Description

The directory specified by path will be used to store downloaded spatial data. By storing the data in a separate directory from the installed package it will not need to be re-downloaded when the package is updated. You simply need to rerun this function to let the package functions know where the data is located.

Usage

set_data_storage(path = "~/.picmaps_data")

Arguments

path

A directory path specifying where spatial data will be stored for the package


sf::st_bbox for a list of sf or sfc objects.

Description

sf::st_bbox for a list of sf or sfc objects.

Usage

st_bbox_list(x, union = TRUE, as_sfc = FALSE)

Arguments

x

A list of sf or sfc objects.

union

Logical. Should the bounding box of the union be returned instead of a list of bounding boxes.

as_sfc

Logical. Should the bounding box (boxes) be returned as sfc objects.

Author(s)

Devin S. Johnson


Check for 0-360 Lat/Lon data

Description

Check for 0-360 Lat/Lon data

Usage

st_check_lon(x)

Arguments

x

An 'sf', 'sfc', 'bbox' object


Divide a polygon into k equal-area polygons

Description

Uses k-means clustering and Voronoi tessellation to divide a polygon into k equal-area polygons.

Usage

st_divide_poly(polygon, k, n_samples = 10000)

Arguments

polygon

The 'sf' polygon object to be divided

k

The number of resulting polygons

n_samples

The number of sample points to perform k-means clustering and divide the polygon.

Author(s)

Google Gemini


Expand Spatial Bounding Box

Description

Expand an sf bounding box by an expansion factor

Usage

st_expand(bbox, ef)

Arguments

bbox

An sf bounding box. See sf::st_bbox.

ef

Expansion factor, must be positive and length 1, 2 or 4. If length(ef)==1 then the expansion factor is applied equally in all 4 directions. If length(ef)==2 then the first refers to the x coordinate and the second is associated with y coordinate expansion. If length(ef)==4 then then the first 2 refer to expansion to the west and east of the x coordinate, and the last to expand the y coordinate in the south and north direction respectively.

Author(s)

Josh M. London


Predicate function for st_filter

Description

Predicate function to use with st_filter such that such that elements of one spatial object are selected if they are not contained at all in the other. See sf::st_within

Usage

st_not_within(x, y, sparse = TRUE, prepared = TRUE, ...)

Arguments

x

object of class sf, sfc or sfg

y

object of class sf, sfc or sfg; if missing, x is used

sparse

ogical; should a sparse index list be returned (TRUE) or a dense logical matrix? See sf::st_within.

prepared

ogical; prepare geometry for x, before looping over y? See sf::st_within.

...

passed on to s2_options


Check if spatial data bounds overlap dateline

Description

Check if spatial data bounds overlap dateline

Usage

st_overlap_dateline(x)

Arguments

x

An 'sf' spatial data object


Divide a polygon into Voronoi tessellations based on closeness to inner polygons instead of points

Description

Divide a polygon into Voronoi tessellations based on closeness to inner polygons instead of points

Usage

st_partition_by_inner_polygons(
  outer_poly,
  inner_polys,
  inner_id,
  sample_density = 5000
)

Arguments

outer_poly

The 'sf' polygon object to be divided

inner_polys

An 'sf' data frame containing inner polygons to partition the outer polygon

inner_id

A column in 'inner_polys' which will label the outer polygon partitions.

sample_density

The density of points used to fill the inner polygons to perform the partitioning. Defaults to 'sample_density = 5000'.

Author(s)

Google Gemini and Devin S. Johnson


sf::st_union for a list of sf or sfc objects.

Description

sf::st_union for a list of sf or sfc objects.

Usage

st_union_list(x)

Arguments

x

A list of sf or sfc objects.

Author(s)

Devin S. Johnson


Palmyra Kingman US EEZ boundary polygon

Description

Palmyra Kingman US EEZ boundary polygon

Usage

wake_eez()