| 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 |
This package is a collection of functions that helps gather spatial data for creating maps in the Pacific Ocean.
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.
Devin S. Johnson <[email protected]> (Maintainer)
American Samoa US EEZ boundary polygon
am_samoa_eez()am_samoa_eez()
Bhattacharyya distance for 2 raster probability densities
bc_raster(r, s)bc_raster(r, s)
r |
SpatRaster object |
s |
SpatRaster object |
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
cenpac()cenpac()
Downloads bathymetery data for map making.
etopo_download(resolution = 60, force = FALSE)etopo_download(resolution = 60, force = FALSE)
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. |
Devin S. Johnson
https://osmdata.openstreetmap.de/data/land-polygons.html
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.
etopo_rast(x, resolution = 60, ...)etopo_rast(x, resolution = 60, ...)
x |
an |
resolution |
Resolution of the ETOPO bathymetry raster, either |
... |
Addtional arguments passed to |
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.
Download Copernicus Marine Service physical oceanography data (2d variables)
fetch_cms_phys_2d( region, variable, layer, timerange, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )fetch_cms_phys_2d( region, variable, layer, timerange, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )
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' |
Devin S. Johnson
Download Copernicus Marine Service physical oceanography data (3d variables)
fetch_cms_phys_3d( region, variable, layer, timerange, verticalrange = 0, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )fetch_cms_phys_3d( region, variable, layer, timerange, verticalrange = 0, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )
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' |
Devin S. Johnson
Download Copernicus Marine Service physical oceanography data (surface values)
fetch_cms_phys_surface( region, variable, layer, timerange, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )fetch_cms_phys_surface( region, variable, layer, timerange, return_type = "raster", progress = FALSE, asset = "ARCO", username = NULL, password = NULL )
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' |
Devin S. Johnson
This function provides the location where 'picMaps' is storing and retrieving spatial data.
get_data_loc()get_data_loc()
Find gradient field of a elevation raster
get_grad(r, scale = TRUE)get_grad(r, scale = TRUE)
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
hawaii_coast(keep = 0.5, union = TRUE, crs = 4326)hawaii_coast(keep = 0.5, union = TRUE, crs = 4326)
keep |
see |
union |
see |
crs |
A coordinate system object, See |
Hawaiian Island EEZ boundary polygon
hawaii_eez()hawaii_eez()
Calculates the appropriate cellsize argument for making
a hexagon grid with st_make_grid.
hex_size(area = NULL, radius = NULL, sep = NULL)hex_size(area = NULL, radius = NULL, sep = NULL)
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. |
Devin S. Johnson
See https://github.com/r-spatial/sf/issues/1505
Import benthic habitat data for the Main Hawaiian Islands
hi_benthic_habitat()hi_benthic_habitat()
HI Official State Coastline
hi_coast_state()hi_coast_state()
Compile full layer of Main Hawaiian Island watersheds
hi_full_watersheds()hi_full_watersheds()
Watershed zones out to 3mi
hi_ridge_to_reef()hi_ridge_to_reef()
Watersheds
hi_watersheds(type = "DAR")hi_watersheds(type = "DAR")
type |
DAR version ('type="DAR"'; default) or 'type="regular"'. |
Howland and Baker Islands US EEZ boundary polygon
howland_baker_eez()howland_baker_eez()
Jarvis Islands US EEZ boundary polygon
jarvis_eez()jarvis_eez()
Johnston Atoll US EEZ boundary polygon
johnston_eez()johnston_eez()
Main Hawaiian Islands Longline Exclusion Zone
longline_exclusion()longline_exclusion()
Coast polygons for the Mariana Islands
mariana_coast(keep = 0.5, union = TRUE, crs = 4326)mariana_coast(keep = 0.5, union = TRUE, crs = 4326)
keep |
see |
union |
see |
crs |
A coordinate system object, See |
Mariana Islands US EEZ boundary polygon
mariana_eez()mariana_eez()
Main Hawaiian Islands Region Boundary
mhi_region()mhi_region()
sf Polygon Object For Plotting and MappingUses downloaded OSM data for constructing an sf polygon coastline data object.
Prior to using this function you must run osm_download.
osm_coast(x, keep = 0.2, union = FALSE)osm_coast(x, keep = 0.2, union = FALSE)
x |
An |
keep |
The amount of data retained after simplification with |
union |
Logical. Should the returned object be returned as a single |
Josh M. London and Devin S. Johnson
Downloads OSM data for plotting telemetry data and use distributions.
osm_download(force = FALSE, clean_shp = TRUE)osm_download(force = FALSE, clean_shp = TRUE)
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. |
Devin S. Johnson and Josh M. London
https://osmdata.openstreetmap.de/data/land-polygons.html
Downloads OSM data for plotting telemetry data and use distributions.
osm_install(zip_file, force = FALSE, clean_shp = TRUE)osm_install(zip_file, force = FALSE, clean_shp = TRUE)
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. |
Devin S. Johnson and Josh M. London
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
palmyra_kingman_eez()palmyra_kingman_eez()
Papahānaumokuākea boundary polygon
papahanaumokuakea()papahanaumokuakea()
Pelagic False Killer Whale Management Area Polygon
pfkw_mgmt()pfkw_mgmt()
Fill raster holes and NAs with local interpolation
raster_fill(r)raster_fill(r)
r |
SpatRaster object |
Uses focal means to infill holes and NAs
Z transform a raster
raster_z(r)raster_z(r)
r |
A spatRaster object from the terra package |
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.
set_data_storage(path = "~/.picmaps_data")set_data_storage(path = "~/.picmaps_data")
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.sf::st_bbox for a list of sf or sfc objects.
st_bbox_list(x, union = TRUE, as_sfc = FALSE)st_bbox_list(x, union = TRUE, as_sfc = FALSE)
x |
A list of |
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 |
Devin S. Johnson
Check for 0-360 Lat/Lon data
st_check_lon(x)st_check_lon(x)
x |
An 'sf', 'sfc', 'bbox' object |
Uses k-means clustering and Voronoi tessellation to divide a polygon into k equal-area polygons.
st_divide_poly(polygon, k, n_samples = 10000)st_divide_poly(polygon, k, n_samples = 10000)
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. |
Google Gemini
Expand an sf bounding box by an expansion factor
st_expand(bbox, ef)st_expand(bbox, ef)
bbox |
An |
ef |
Expansion factor, must be positive and length 1, 2 or 4.
If |
Josh M. London
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
st_not_within(x, y, sparse = TRUE, prepared = TRUE, ...)st_not_within(x, y, sparse = TRUE, prepared = TRUE, ...)
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
st_overlap_dateline(x)st_overlap_dateline(x)
x |
An 'sf' spatial data object |
Divide a polygon into Voronoi tessellations based on closeness to inner polygons instead of points
st_partition_by_inner_polygons( outer_poly, inner_polys, inner_id, sample_density = 5000 )st_partition_by_inner_polygons( outer_poly, inner_polys, inner_id, sample_density = 5000 )
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'. |
Google Gemini and Devin S. Johnson
sf::st_union for a list of sf or sfc objects.sf::st_union for a list of sf or sfc objects.
st_union_list(x)st_union_list(x)
x |
A list of |
Devin S. Johnson
Palmyra Kingman US EEZ boundary polygon
wake_eez()wake_eez()