Package 'raadtools'

Title: Tools for Synoptic Environmental Spatial Data
Description: Tools for reading, plotting and manipulating spatial data, particularly from remote sensing and model output.
Authors: Michael D. Sumner [aut, cre], Ben Raymond [ctb]
Maintainer: Michael D. Sumner <[email protected]>
License: GPL-3
Version: 0.8.0
Built: 2026-10-13 08:10:57 UTC
Source: https://github.com/AustralianAntarcticDivision/raadtools

Help Index


R tools for spatial data, extensions using terra to read and extract

Description

Tools in R for reading, plotting and manipulating spatial data, originally used at the Australian Antarctic Division (AAD).

Details

read functions like readsst will read a data set by date-time vector, with a set of shared arguments that work the same and documented against this dummy function.

Author(s)

Michael D. Sumner [email protected]

Options

Maintainer: Michael D. Sumner [email protected]

See Also

Useful links:


Load raw list of all files available to raadtools from the data repository.

Description

Raw list of all files.

Usage

allfiles(...)

Arguments

...

reserved for future use, currently ignored

Value

data.frame with columns fullname with all file paths


Antarctic altimetry files

Description

A one-row-per-date catalogue of the Antarctic altimetry time series. Each source file found by raadfiles::altimetry_antarctica_files() holds the whole of its own series, one band per date, so this reads the time dimension of each and returns a row per date with the band to read within its file.

Usage

altimetry_antarctica_daily_files()

Value

data.frame of date, fullname, band and root

See Also

read_altimetry_antarctica_daily()


AMPS files

Description

AMPS files

Usage

amps_d1_icefiles(data.source = "", time.resolution = "12hourly", ...)

Arguments

data.source

ignored, reserved for future use

time.resolution

time resolution data to read, 6hourly only for now

...

reserved for future use, currently ignored


AMPS GRIB file metadata

Description

GRIB format metadata from the Antarctic Mesoscale Prediction System (AMPS) files.

Format

amps_metadata A data frame with 8 columns. The columns represent

Band the band number
GRIB_COMMENT the data measured
GRIB_ELEMENT the data name
GRIB_FORECAST_SECONDS forecast seconds
GRIB_REF_TIME text reference time
GRIB_SHORT_NAME short name
GRIB_UNIT text unit
GRIB_VALID_TIME text valid time

Details

A snapshot of one 2015-era d1 file, not a current index. The band layout has changed three times since - see the notes at the top of R/amps.R - so readamps_d1wind and readamps_d1ice find their bands by name in the file being read rather than by position in this table.

Examples

print(amps_metadata)
## u_wind_at_900 <- read  ## unfinished

Aurora Australis voyage track

Description

Voyage track data from the Aurora Australis

Format

aurora A data frame with 3 columns. The columns represent

LONGITUDE_DEGEAST Longitude values
LATITUDE_DEGNORTH Latitude values
DATE_TIME_UTC Date-time values (POSIXct)

Details

This is a sample of the "Aurora Australis Voyage 3 2012/13 Track and Underway Data".

References

http://gcmd.nasa.gov/KeywordSearch/Metadata.do?Portal=amd_au&MetadataView=Full&MetadataType=0&KeywordPath=&OrigMetadataNode=AADC&EntryId=201213030

Examples

## Not run: 
## These data were obtained like this
base <- "http://gcmd.gsfc.nasa.gov/KeywordSearch/RedirectAction.do?target"
b1 <-   "=F4t70bSf87FLsT1TNxR9TSPS74xbHAdheLQcH5Z5PMmgzJ9t%2Bi%2FEs1e8Fl61"
b2 <-   "MPhKjo9qxb2f9wyA%0D%0AoE1kjJ8AMcpFlMMRH7Z6umgNLsGMnWPeQdU7mZHMp%2"
b3 <-   "FtqMpahIrde%2F%2B9%2FZWAkIFrh2bhIiNfl4I9J%0D%0A5KBX9g5Wf7I9JdOgqY"
b4 <-   "bDdpj0iM1K%2BA%3D%3D"
aurora2013 <- read.csv(paste(base, b1, b2, b3, b4, collapse = ""), stringsAsFactors = FALSE)
aurora2013$DATE_TIME_UTC <- as.POSIXct(aurora2013$DATE_TIME_UTC, tz = "GMT")
## get a daily sample
aurora <- aurora2013[,c("LONGITUDE_DEGEAST", "LATITUDE_DEGNORTH", "DATE_TIME_UTC")]
aurora <- aurora[!duplicated(format( aurora$DATE_TIME_UTC, "%Y-%j")), ]
aurora <- aurora[order(aurora$DATE_TIME_UTC), ]
save(aurora, file = "aurora.rda")

## End(Not run)

Title

Description

Title

Usage

ccmp_files(time.resolution = "6hourly", ...)

Arguments

time.resolution

time resolution: "daily" or "monthly"

...

passed to underlying reader

Value

data frame of file paths

Examples

ccmp_files()

Ocean colour colours for chlorophyll-a.

Description

Ocean colour palette for chlorophyll-a.

Usage

chl.pal(x, palette = FALSE, alpha = 1)

Arguments

x

a vector of data values or a single number

palette

logical, if TRUE return a list with matching colours and values

alpha

value in 0,1 to specify opacity

Details

Flexible control of the chlorophyll-a palette. If x is a single number, the function returns that many colours evenly spaced from the palette. If x is a vector of multiple values the palette is queried for colours matching those values, and these are returned. If x is missing and palette is FALSE then a function is returned that will generate n evenly spaced colours from the palette, as per colorRampPalette.

Value

colours, palette, or function, see Details

References

Derived from http://oceancolor.gsfc.nasa.gov/DOCS/palette_chl_etc.txt.

Examples

## Not run: 
chl <- readchla(xylim = c(100, 110, -50, -40))
## just get a small number of evenly space colours
plot(chl, col = chl.pal(10))
## store the full palette and work with values and colours
pal <- chl.pal()
## the standard full palette
plot(chl, breaks = pal$breaks, col = pal$cols)
## a custom set of values with matching colours
plot(chl, col = chl.pal(pal$breaks[seq(1, length(pal$breaks), length = 10)]))
## any number of colours stored as a function
myfun <- chl.pal()
plot(chl, col = myfun(18))
## just n colours
plot(chl, col = chl.pal(18))

## End(Not run)

Chlorophyll-a

Description

Chlorophyll-a for the Southern Ocean

Usage

chlafiles(
  time.resolution = c("weekly", "monthly"),
  product = c("johnson", "oceancolor"),
  platform = c("MODISA", "SeaWiFS"),
  ...
)

Arguments

time.resolution

weekly (8day) or monthly

product

choice of chla product, see readchla

platform

one of "MODISA" or "SeaWiFS"

...

reserved for future use, currently ignored

Details

This function generates a list of available chlorophyll-a files, including SeaWiFS and MODIS.

Value

data.frame


Coast map

Description

Coastline data set as SpatialPolygons, currently not supported.

Usage

coastmap(
  map = c("world", "world2", "ant_coast", "ant_coast01", "ant_coast10",
    "Countries_hires", "world1", "world360", "cst00_polygon", "cst01_polygon",
    "cst10_polygon"),
  ...
)

Arguments

map

A named map source

...

arguments passed to worker functions

Details

This function reads and returns a coastline polygon data set, either from the source or serialized cache (.Rdata). Data source locations are controlled by options.

The following named data sets were available.

"world", "world2" - Atlantic and Pacific versions of maptools wrld_simpl ("world1", "world360" are aliases) "ant_coast", "ant_coast01", "ant_coast10" - AAD Antartic coast in full, "1 mill", and "10 mill" resolution ("cst00_polygon", "cst01_polygon", and "cst10_polygon" are aliases) "Countries_hires" - the "CIA" world map exported from the Manifold GIS data set

Value

SpatialPolygonsDataFrame or SpatialPolygons (world1/2)


This is a list of often used projections, in PROJ

Description

Each element can be looked up by name, see Examples

Usage

commonprojections

Warning

This should be use only for a convenient reference to look up the projection strings commonly in use. There's no guarantee that this would be appropriate and you should seek cartographic expertise.

References

http://www.spatialreference.org

See Also

crs

Examples

names(commonprojections)
commonprojections[["polar"]]

Circumpolar ROMS files.

Description

These were an experiment provided by Stuart Corney of UTAS, consider deprecated.

Usage

cpolarfiles(...)

Arguments

...

ignored

Value

data frame of fullname, date

Examples

cpolarfiles()

AVISO ocean currents files

Description

Load file names and dates of AVISO current data

Usage

currentsfiles(time.resolution = c("daily", "weekly"), ...)

Arguments

time.resolution

time resolution to load

...

reserved for future use, currently ignored

Details

A data.frame of file names and dates

Value

data.frame of file names and dates

See Also

readcurr


Load metadata and location of files of polar climatological and other summary environmental data

Description

This function loads the latest cache of stored files for these products, which are available from http://webdav.data.aad.gov.au/data/environmental/derived/antarctic/

Usage

derivaadcfiles(products, ...)

Arguments

products

which derived product

...

reserved for future use, currently ignored

Value

data.frame of file and date

See Also

readderivaadc and derivaadcproducts

Examples

(prods <- derivaadcproducts())
readderivaadc(sample(prods, 1L))

List all derived data products available through readderivaadc

Description

List all derived data products available through readderivaadc

Usage

derivaadcproducts()

Value

character vector of product names

See Also

readderivaadc and derivaadcfiles


Load metadata and location of files of derived sea ice data products.

Description

This function loads the latest cache of stored files for ice products, currently only daily NSIDC southern hemisphere is available.

Usage

derivicefiles(product = "time_since_melt", ...)

Arguments

product

which derived product

...

reserved for future use, currently ignored

Value

data.frame of file and date


Distance to a sea ice 'edge'.

Description

Calculate the shortest distance (metres) to a threshold sea ice contour. If in doubt use distance_to_ice_edge, the definition of the edge is not straightforward, especially so for the higher resolution products and near the coast. distance_to_ice_edge computes a single "main" edge at continental scale distance_to_ice computes all distances to any ice at threshold concentration

Usage

distance_to_ice_edge(
  date,
  threshold = 0.15,
  xylim = NULL,
  hemisphere = c("south", "north"),
  product = c("cdr", "nsidc"),
  min_length = NULL,
  returnfiles = FALSE,
  inputfiles = NULL,
  latest = TRUE,
  ...
)

distance_to_ice(
  date,
  threshold = 0.15,
  xylim = NULL,
  hemisphere = c("south", "north"),
  product = c("cdr", "nsidc"),
  returnfiles = FALSE,
  inputfiles = NULL,
  latest = TRUE,
  ...
)

Arguments

date

date or dates of data to read

threshold

the sea ice concentration threshold to contour at, as a fraction - 0.15 is the conventional 15 percent ice edge

xylim

spatial extents to crop, or a SpatRaster (or Raster*) template to warp onto when hemisphere = "both"

hemisphere

"north" or "south", default is "south"

product

"cdr" (default) for the Climate Data Record, or "nsidc" for NSIDC-0051 v2

min_length

if set, keep every contour line longer than this many metres rather than only the single longest one

returnfiles

if TRUE, return file catalog

inputfiles

optional pre-filtered file catalog

latest

if TRUE and date missing, return latest available

...

passed to underlying reader

Details

The distance is always positive, use readice in the usual way to determine if a location is inside or out of the ice field itself. (If inside means zero distance to ice for you then set it explicitly based on the concentration a point is in.)

The contour is measured as lines, so the distance reported for a cell is its distance to the edge itself and not to the nearest contour vertex.

The sea ice product contoured is whatever readice reads, which is the NOAA/NSIDC Climate Data Record by default; pass product = "nsidc" for NSIDC-0051 v2. Both are 25km products on which a single min_length free distance_to_ice_edge gives a clean continental edge. Finer products (AMSR2 at 3km, say) break the edge into many pieces and are better served by setting min_length to drop the short ones - but they are not available through readice, so contour them directly with terra::as.contour.

Future work may generalize this to other data sources.

Value

SpatRaster of distances (metres) to this date's sea ice edge

Note

beware that any queried location outside of this layer's range will be undetermined, and the external boundary of this layer is not constant with respect to the pole, and that in general a location may be closer to ice in the opposite hemisphere.

The argument hemisphere may be north or south (default is south), but this will only work if your locations are on the actual map, so it's not possible to request the distance to ice in both poles for any point.

Examples

## Not run: 
terra::plot(distance_to_ice(latest = TRUE))
terra::plot(distance_to_ice_edge(latest = TRUE))
## every piece of the edge longer than 500km, rather than just the longest
terra::plot(distance_to_ice_edge(min_length = 5e5))
extract(distance_to_ice, aurora[17:25, ])
extract(distance_to_ice, aurora[17:25, ], hemisphere = "south")
# library(trip)
# extract(distance_to_ice_edge, walrus818[seq(50, 400, by = 20), ], hemisphere = "north")

## End(Not run)

Extract values at points in space and time

Description

Extract values from a raadtools reader at points that each carry their own date-time. x is a read function such as readsst(), y a data.frame of longitude, latitude and date-time in that column order.

Usage

## S4 method for signature 'function,data.frame'
extract(x, y, ctstime = FALSE, when = "previous", ...)

Arguments

x

a raadtools read function

y

a data.frame of longitude, latitude, date-time

ctstime

interpolate between the two slices bracketing each point (TRUE), or take the value from a single slice (FALSE, the default)

when

which slice a point takes its value from when ctstime is FALSE: "previous" is what raadtools has always done, "nearest" is what it always documented. See the note below.

...

passed to xyt::extract_xyt() and on to the read function

Details

Only the time slices the points actually need are read, and each is read once. The work is done by xyt::extract_xyt(); this is the raadtools front door onto it, so that extract(readsst, xyt) goes on meaning what it has always meant.

xyt takes further arguments that are passed through here: method for the spatial interpolation, fact to aggregate each slice before reading, tolerance to return NA for points that fall too far from any slice in time, and map to spread the reads over mirai daemons. See xyt::extract_xyt().

Value

a numeric vector, one value per row of y

Note

when = "previous" is the default here rather than xyt's own "nearest", because that is what the old findInterval() implementation did and it is what existing results were computed with. The documentation always said "nearest in time", so the two have disagreed for years. Changing the default should be a deliberate decision, not a side effect of this move.

See Also

xyt::extract_xyt(), readsst()

Examples

a <- structure(list(x = c(174, 168, 156, 111, 99, 64, 52, 46, -4,
-15, -30, -38, -47, -62, -87, -127, -145, -160, -161), y = c(-72,
-39, -50, -58, -35, -38, -48, -60, -48, -35, -37, -51, -68, -72,
-69, -54, -40, -49, -54)), .Names = c("x", "y"), row.names = c(NA,
-19L), class = "data.frame")

a$time <- structure(c(5479, 5479, 5479, 5479, 5479, 5479, 5479, 5479, 5479,
5479, 5479, 5489, 5529, 5529, 5529, 5579, 5579, 5579, 5579), class = "Date")
extract(readsst, a)
extract(readsst, a, method = "bilinear")
a$time <-  sort(as.Date("2005-01-01") + sample(c(0, 0, 0, 8, 20, 50), nrow(a), replace = TRUE))
extract(readsst, a)

Fast ice files

Description

Provided by Alex Fraser

Usage

fasticefiles(...)

Arguments

...

ignored

Details

This function wraps a raadfiles function fasticefiles, but expands the file list out to individual bands.

Value

data.frame of fullname, date and band

Examples

fraser_fasticefiles()

Fronts map data for the Southern Ocean

Description

Load spatial map of fronts data.

Usage

frontsmap(map = c("park", "orsi"))

Arguments

map

name of map to load

Details

Currently ORSI or PARK is the only supported layers.

"park" = Southern Ocean fronts as determined by Park and Durand, doi: 10.17882/59800

"orsi" - the ORSI fronts derived from the files provided by the WOCE Atlas, see References

Value

SpatialLinesDataFrame

References

http://woceatlas.tamu.edu/Sites/html/atlas/SOA_DATABASE_DOWNLOAD.html


GHRSST L4 files

Description

Data frame of file names and dates.

Usage

ghrsstfiles()

Value

data.frame


Load metadata and location of files of sea ice data products.

Description

This function loads the latest cache of stored files for ice products.

Usage

icefiles(
  time.resolution = "daily",
  product = c("cdr", "nsidc"),
  hemisphere = c("south", "north"),
  ...
)

Arguments

time.resolution

daily or monthly files?

product

choice of sea ice product, see readice

hemisphere

north or south

...

reserved for future use, currently ignored

Details

The 'fullname' is the path to the source file.

product = "cdr" (the default) is the NOAA/NSIDC Climate Data Record, G02202 V6. product = "nsidc" is NSIDC-0051 v2, which is what icefiles used to return and what read_nsidc_ice_daily still reads.

Value

data.frame of file and date

Examples

## Not run: 
icf <- icefiles()
icf[nrow(icf), ]

## End(Not run)

Maps of places

Description

Read map images.

Usage

imagemap(map = c("ibcso_background_hq"), fact = 1L)

Arguments

map

name of the map to load

fact

resize factor, see aggregate

Details

The ancient lost art of cartography.

ibcso_background: The IBCSO RGB-map rasterlayer in high resolution

Value

SpatRaster, with R G B bands

References

http://www.ibcso.org/data.html


Nuyina underway track

Description

Voyage track data from the Nuyina

Format

aurora A data frame with 9 columns. The columns represent longitude latitude date_time_utc air_pressure port_longwave_irradiance port_air_temperature precipitation_rate sea_water_salinity sea_water_temperature

Details

This is a sample of the Nuyina underway in 2023.

References

see data-raw for extraction

Examples

range(nuyina$date_time_utc)

Load metadata and location of files of ocean colour data products.

Description

This function loads the latest cache of stored files for NASA ocean colour products.

Usage

ocfiles(
  time.resolution = c("daily", "weekly", "monthly", "weekly32"),
  product = c("MODISA", "SeaWiFS", "VIIRS"),
  varname = c("CHL", "RRS", "POC", "KD490", "NPP_PAR", "SNPP_CHL", "SNPP_RRS"),
  type = c("L3m", "L3b"),
  bz2.rm = TRUE,
  ext = c("nc", "main"),
  ...
)

Arguments

time.resolution

daily or monthly files?

product

choice of ocean colour sensor

varname

which variable (or set of variables)

type

which level of data

bz2.rm

ignore files that are compressed

ext

which extension, e.g. "nc" or "main"

...

reserved for future use, currently ignored

Value

data.frame of file and date


Create a query grid

Description

Create a grid of query values for of longitude, latitude, and date.

Usage

query_grid(lon, lat, date)

Arguments

lon

vector of longitudes in the grid

lat

vector of latitudes in the grid

date

vector of dates in the grid

Details

This be used as the second argument to extract() for general 'point-in-time' value extraction.

The ouput is a data frame of the grid expanded, a row for every combination of longitude, latitude, date - so can be quite large (!) so be careful with very fine resolution or long series.

Examples

lon <- c(100, 110, 120)
lat <-seq(-60, -40, by = 5)
dts <- seq(as.Date("2002-03-03"), by = "5 days", length.out = 10)
qd <- query_grid(lon = lon, lat = lat, date = dts)
## use bilinear to ensure we get an interpolate value in the grid
qd$sst <- extract(readsst, qd, method = "bilinear")
## ssha
qd$ssha <- extract(readssh, qd, ssha = TRUE, method = "bilinear")
qd$wind_mag <- extract(readwind, qd, magonly = TRUE, method = "bilinear")

raadtools

Description

Dummy function

Usage

raadtools(
  date,
  time.resolution = "daily",
  lon180 = TRUE,
  setNA = TRUE,
  latest = FALSE,
  returnfiles = FALSE,
  ...
)

Arguments

date

date or dates of data to read,

time.resolution

time resoution data to read, daily or monthly

lon180

defaults to TRUE, to "rotate" Pacific view [0, 360] data to Atlantic view [-180, 180]

setNA

mask out land values (only applies to monthly time.resolution)

latest

if TRUE (and date not supplied) return the latest time available

returnfiles

ignore options and just return the file names and dates

...

passed to writeRaster, primarily for filename

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

inputfiles

input the files data base to speed up initialization


Load metadata and location of files of Rapid Response imagery.

Description

This function loads the latest cache of stored files for rapid response products.

Usage

rapid_responsefiles(product = c("aqua", "terra"), ...)

Arguments

...

reserved for future use, currently ignored

Details

We acknowledge the use of Rapid Response imagery from the Land Atmosphere Near-real time Capability for EOS (LANCE) system operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.

Value

data.frame of file and date

Examples

## Not run: 
rf <- rapid_responsefiles()
range(rf$date)

## End(Not run)

Read Antarctic altimetry

Description

Read one or more dates of gridded Antarctic sea level anomaly, catalogued by altimetry_antarctica_daily_files().

Usage

read_altimetry_antarctica_daily(
  date,
  xylim = NULL,
  varname = c("sla", "std_sla", "number_sla"),
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read,

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

varname

variable to read: "sla" (the anomaly, the default), "std_sla" (its standard deviation) or "number_sla" (the count of observations behind it)

latest

if TRUE (and date not supplied) return the latest time available

returnfiles

ignore options and just return the file names and dates

...

passed to writeRaster, primarily for filename

inputfiles

input the files data base to speed up initialization

Details

The source has no georeference of its own, so the extent and CRS are asserted here: a square of 8750000 m about the pole, in Lambert azimuthal equal area on +lat_0=-90 +lon_0=-90.

Value

SpatRaster with one layer per date, or a data.frame of files if returnfiles = TRUE

See Also

altimetry_antarctica_daily_files()

Examples

## Not run: 
read_altimetry_antarctica_daily(latest = TRUE)

## End(Not run)

Read AMSR2 sea ice concentration (3km)

Description

Read Antarctic sea ice concentration from AMSR2 sensor at 3.125km resolution.

Usage

read_amsr_ice_3k_daily(
  date,
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_amsr2_3k_ice(
  date,
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop (in polar stereographic coordinates), or NULL.

setNA

logical, mask flag values (above 1) as NA? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Data are in Antarctic polar stereographic projection. This is the highest resolution passive microwave sea ice product, available from 2012 onwards. Concentration is returned as a fraction (0-1).

Value

SpatRaster with time dimension set.

See Also

read_amsr_ice_daily for longer time series at 6km


Read AMSR sea ice concentration (6km)

Description

Read Antarctic sea ice concentration from combined AMSR-E (2002-2011) and AMSR2 (2012+) sensors at 6.25km resolution.

Usage

read_amsr_ice_daily(
  date,
  xylim = NULL,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_amsr_ice(
  date,
  xylim = NULL,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop (in polar stereographic coordinates), or NULL.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Data are in Antarctic polar stereographic projection. Both sensor eras are combined into a continuous time series. Concentration is returned as a fraction (0-1); the files that store percentages are scaled down to match.

Value

SpatRaster with time dimension set.

See Also

read_amsr_ice_3k_daily for higher resolution AMSR2 data


Read AMSR2 sea ice data (6km)

Description

Using the TIF files (these are 2012 onwards)

Usage

read_amsr2_ice(
  date,
  xylim = NULL,
  latest = TRUE,
  ...,
  setNA = TRUE,
  returnfiles = FALSE,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

xylim

spatial extents to crop, or a SpatRaster (or Raster*) template to warp onto when hemisphere = "both"

latest

if TRUE and date missing, return latest available

...

passed to underlying reader

setNA

mask special values as NA

returnfiles

if TRUE, return file catalog

inputfiles

optional pre-filtered file catalog

Details

This function relies on the file-listing of raadfiles::amsr2_daily_files(). Concentration is returned as a fraction (0-1).

Value

SpatRaster

See Also

raadfiles::amsr2_daily_files


Read AMSRE sea ice data (6km)

Description

Using the TIF files (these are 2012 onwards)

Usage

read_amsre_ice(
  date,
  xylim = NULL,
  latest = TRUE,
  ...,
  returnfiles = FALSE,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

xylim

spatial extents to crop, or a SpatRaster (or Raster*) template to warp onto when hemisphere = "both"

latest

if TRUE and date missing, return latest available

...

passed to underlying reader

returnfiles

if TRUE, return file catalog

inputfiles

optional pre-filtered file catalog

Details

This function relies on the file-listing of raadfiles::amsre_daily_files(). Concentration is returned as a fraction (0-1).

Value

SpatRaster

See Also

raadfiles::amsre_daily_files read_amsr2_ice


Read CCMP wind files

Description

read_ccmp picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see read_ccmp_wind_6hourly.

Usage

read_ccmp(
  date,
  time.resolution = c("6hourly"),
  xylim = NULL,
  lon180 = FALSE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  nobsonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

time resolution, currently only "6hourly"

xylim

spatial extents to crop

lon180

if TRUE, use Atlantic-centered longitude (default FALSE)

magonly

return wind speed only

dironly

return wind direction only

uonly

return U component only

vonly

return V component only

nobsonly

return number of observations only

latest

if TRUE and date missing, return latest

returnfiles

if TRUE, return file catalog

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

Value

SpatRaster, or tibble if returnfiles = TRUE

References

http://www.remss.com

See Also

read_ccmp_wind_6hourly for modern terra-based reader


Read CCMP wind data

Description

Read wind velocity from RSS Cross-Calibrated Multi-Platform (CCMP) products.

Usage

read_ccmp_wind_6hourly(
  date,
  time.resolution = "6hourly",
  xylim = NULL,
  lon180 = FALSE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  nobsonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

time.resolution

time resolution, currently only "6hourly" supported.

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default FALSE (Pacific-centered).

magonly

logical, return wind speed only?

dironly

logical, return wind direction only?

uonly

logical, return U (eastward) component only?

vonly

logical, return V (northward) component only?

nobsonly

logical, return number of observations only?

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog (from ccmp_files()).

Details

CCMP provides RSS VAM 6-hour analyses starting from NCEP GFS wind analyses. Data contain U (eastward) and V (northward) wind components as subdatasets in the same file. By default both components are returned as a 2-layer SpatRaster. Use the component arguments to return derived quantities:

  • magonly = TRUE: wind speed (magnitude), sqrt(U^2 + V^2)

  • dironly = TRUE: wind direction (degrees, meteorological: N=0, E=90, S=180, W=270)

  • uonly = TRUE: U component only

  • vonly = TRUE: V component only

  • nobsonly = TRUE: number of observations only

Only one of these flags may be TRUE. When reading multiple dates with the default (both U and V), only one timestep can be read at a time.

Data are 6-hourly on a global 0.25 degree grid.

Value

SpatRaster. If default (no component flag), 2 layers named "U", "V". With a component flag, single layer per date. Time dimension is set.

References

http://www.remss.com

See Also

read_ccmp for legacy interface, ccmp_files for file catalog

Examples

## Not run: 
# Latest wind (U and V)
uv <- read_ccmp_wind_6hourly()

# Wind speed - can read multiple dates
speed <- read_ccmp_wind_6hourly(c("2023-01-15", "2023-01-15 06:00"), magonly = TRUE)

# Number of observations
nobs <- read_ccmp_wind_6hourly("2023-01-15", nobsonly = TRUE)

## End(Not run)

Read CERSAT SSM/I sea ice concentration (12.5km)

Description

Read Antarctic sea ice concentration from CERSAT SSM/I at 12.5km resolution.

Usage

read_cersat_ice_daily(
  date,
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_cersat_ice(
  date,
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop (in polar stereographic coordinates), or NULL.

setNA

logical, mask flag values (above 1) as NA? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Data are in Antarctic polar stereographic projection. This is the longest passive microwave sea ice record, available from 1991 onwards. Concentration is returned as a fraction (0-1).

Value

SpatRaster with time dimension set.

See Also

read_amsr_ice_daily for AMSR data


Read daily chlorophyll-a

Description

read_chla_daily picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see read_oc_chl_daily.

Usage

read_chla_daily(
  date,
  time.resolution = "daily",
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_chla_weekly(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_chla_monthly(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_par(
  date,
  time.resolution = "8D",
  xylim = NULL,
  lon180 = FALSE,
  nobsonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

time.resolution

ignored, use specific functions for different resolutions

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

varname

subdataset to read, default "chlor_a".

setNA

ignored (for backward compatibility)

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog (from ocfiles()).

Value

SpatRaster

See Also

read_oc_chl_daily


Read CMEMS absolute dynamic topography

Description

Read absolute dynamic topography (ADT) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_adt_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_adt_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.

See Also

readssh for legacy interface


Read CMEMS geostrophic current direction

Description

Read geostrophic current direction derived from ugos and vgos components of CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_current_direction_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Direction is computed using oceanographic convention: direction the current is flowing TO, in degrees where N=0, E=90, S=180, W=270.

Value

SpatRaster with time dimension set. Values in degrees (0-360).

See Also

readcurr for legacy interface


Read CMEMS geostrophic current speed

Description

Read geostrophic current speed (magnitude) derived from ugos and vgos components of CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_current_speed_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Speed is computed as sqrt(ugos^2 + vgos^2).

Value

SpatRaster with time dimension set. Values in m/s.

See Also

readcurr for legacy interface


Read CMEMS altimetry error field

Description

Read formal mapping error from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_err_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_err_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.


Read CMEMS sea level anomaly

Description

Read sea level anomaly (SLA) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_sla_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_sla_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.

See Also

readssh for legacy interface


Read CMEMS geostrophic current U component

Description

Read eastward geostrophic current velocity (ugos) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_ugos_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_ugos_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.

See Also

readcurr for legacy interface with U/V decomposition options


Read CMEMS geostrophic current anomaly U component

Description

Read eastward geostrophic current anomaly (ugosa) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_ugosa_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_ugosa_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.


Read CMEMS geostrophic current V component

Description

Read northward geostrophic current velocity (vgos) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_vgos_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_vgos_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.

See Also

readcurr for legacy interface with U/V decomposition options


Read CMEMS geostrophic current anomaly V component

Description

Read northward geostrophic current anomaly (vgosa) from CMEMS SEALEVEL_GLO_PHY_L4 product.

Usage

read_cmems_vgosa_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_vgosa_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension set.


Read Copernicus ocean surface currents

Description

Read geostrophic current velocity from Copernicus/AVISO altimetry products.

Usage

read_copernicus_current_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_aviso_current_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, ensure Atlantic-centered longitude? Default TRUE.

magonly

logical, return current speed only?

dironly

logical, return current direction only?

uonly

logical, return U (eastward) component only?

vonly

logical, return V (northward) component only?

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Data contain U (eastward) and V (northward) velocity components. By default both components are returned as a 2-layer SpatRaster. Use the component arguments to return derived quantities instead:

  • magonly = TRUE: current speed (magnitude), sqrt(U^2 + V^2)

  • dironly = TRUE: current direction (degrees, oceanographic convention)

  • uonly = TRUE: U component only

  • vonly = TRUE: V component only

Only one of these flags may be TRUE. When reading multiple dates with the default (both U and V), only one date can be read at a time - use a component flag to read time series.

Data are on a global 0.25 degree grid. Source orientation varies by file; use lon180 = TRUE (default) to ensure Atlantic-centered output (-180 to 180).

Value

SpatRaster. If default (no component flag), 2 layers named "U", "V". With a component flag, single layer per date. Time dimension is set.

See Also

readcurr for legacy interface

Examples

## Not run: 
# Latest currents (U and V)
uv <- read_copernicus_current_daily()

# Current speed only - can read multiple dates
speed <- read_copernicus_current_daily(c("2023-01-15", "2023-06-15"), magonly = TRUE)

# Direction
dir <- read_copernicus_current_daily("2023-01-15", dironly = TRUE)

## End(Not run)

Read Earth Gravitation Model

Description

Global 2.5 Minute Geoid Undulations, a big raster from multiple files. We just create a temporary virtual raster from the source files, and return as a SpatRaster.

Usage

read_geoid(xylim = NULL, force = FALSE)

Arguments

xylim

an extent, in longlat, or an object that provides one

force

if TRUE ignore cached virtual saved file, and recompute (try this if it otherwise fails)

Details

Each file is an ESRI GRID raster data set of 2.5-minute geoid undulation values covering a 45 x 45 degree area. Each raster file has a 2.5-minute cell size and is a subset of the global 2.5 x 2.5-minute grid of pre-computed geoid undulation point values found on the EGM2008-WGS 84 Version web page. This ESRI GRID format represents a continuous surface of geoid undulation values where each 2.5-minute raster cell derives its value from the original pre-computed geoid undulation point value located at the SW corner of each cell.

Value

SpatRaster, longitude latitue grid of geoid level

Examples

## Not run: 
geoid <- read_geoid()

## End(Not run)

Relative lead frequencies for the polar oceans

Description

Average Lead-Frequency for the Arctic for winter months November-April 2002/03-2018/19 based on daily lead composites as derived from MOD/MYD-29 IST 5 min granules

Usage

read_leads_clim_south(xylim = NULL)

read_leads_clim_north(xylim = NULL)

read_leads_clim(hemisphere = c("south", "north"), xylim = NULL, ...)

References

F. Reiser, S. Willmes, G. Heinemann (2020), A new algorithm for daily sea ice lead identification in the Arctic and Antarctic winter from thermal-infrared satellite imagery, Data subm.

Examples

read_leads_clim()
read_leads_clim_north(xylim = terra::ext(c(-1, 1, -1, 1) * 50000))
south <- read_leads_clim_south()

## hone in on Mawson
pt <- reproj::reproj_xy(cbind(62 + 52/60, -(67 +  36/60)), terra::crs(south), source = "+proj=longlat")
lead <- read_leads_clim_south(xylim = terra::ext(pt[1] + c(-1, 1) * 250000, pt[2] + c(-1, 1) * 250000))
plot(lead, col = grey.colors(100))
abline(v = pt[1], h = pt[2])

Read Mixed Layer Depth climatology

Description

Read the Sallee et al. (2013) Southern Ocean Mixed Layer Depth climatology.

Usage

read_mld_climatology(date, xylim = NULL, returnfiles = FALSE, ...)

readmld(date, xylim = NULL, returnfiles = FALSE, ...)

Arguments

date

date(s) to select month from. Default returns all 12 months.

xylim

extent to crop, anything acceptable to terra::ext().

returnfiles

if TRUE, return file info instead of data.

...

currently ignored.

Details

This is a monthly climatology (12 layers, one per month) covering the Southern Ocean south of 30S. Data represent typical mixed layer depth for each month, not actual dates.

When a date is provided, the corresponding month is extracted. Multiple dates will return multiple layers (one per unique month).

Value

SpatRaster with one layer per month requested.

References

Sallee, J.-B., et al. (2013). Assessment of Southern Ocean mixed-layer depths in CMIP5 models: Historical bias and forcing response. Journal of Geophysical Research: Oceans, 118.

Examples

## Not run: 
# All 12 months
mld <- read_mld_climatology()

# Just January
mld_jan <- read_mld_climatology("2020-01-15")

# Summer months
mld_summer <- read_mld_climatology(c("2020-12-01", "2020-01-01", "2020-02-01"))

## End(Not run)

Read NCEP2 wind data

Description

Read wind velocity from NCEP2 reanalysis products.

Usage

read_ncep2_wind_6hourly(
  date,
  time.resolution = "6hourly",
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

time.resolution

time resolution, currently only "6hourly" supported.

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, ensure Atlantic-centered longitude? Default TRUE.

magonly

logical, return wind speed only?

dironly

logical, return wind direction only?

uonly

logical, return U (eastward) component only?

vonly

logical, return V (northward) component only?

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog (from windfiles()).

Details

Data contain U (eastward) and V (northward) wind components stored in separate files. By default both components are returned as a 2-layer SpatRaster. Use the component arguments to return derived quantities:

  • magonly = TRUE: wind speed (magnitude), sqrt(U^2 + V^2)

  • dironly = TRUE: wind direction (degrees, meteorological: N=0, E=90, S=180, W=270)

  • uonly = TRUE: U component only

  • vonly = TRUE: V component only

Only one of these flags may be TRUE. When reading multiple dates with the default (both U and V), only one timestep can be read at a time.

Data are 6-hourly on a global 2.5 degree grid (144x73 cells).

Value

SpatRaster. If default (no component flag), 2 layers named "U", "V". With a component flag, single layer per date. Time dimension is set.

See Also

readwind for legacy interface, windfiles for file catalog

Examples

## Not run: 
# Latest wind (U and V)
uv <- read_ncep2_wind_6hourly()

# Wind speed - can read multiple dates
speed <- read_ncep2_wind_6hourly(c("2023-01-15", "2023-01-15 06:00"), magonly = TRUE)

# Direction
dir <- read_ncep2_wind_6hourly("2023-01-15", dironly = TRUE)

## End(Not run)

Read NSIDC CDR daily sea ice concentration

Description

Read the NOAA/NSIDC Climate Data Record of passive microwave sea ice concentration (G02202 V6, 25km) for a single hemisphere.

Usage

read_nsidc_cdr_daily(
  date,
  hemisphere = c("south", "north"),
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

hemisphere

"south" (default) or "north".

xylim

extent to crop (in native projection coordinates), or NULL.

setNA

logical, mask special values (land, coast, missing) to NA? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

The CDR is what readice and icefiles reach for by default. read_nsidc_ice_daily reads NSIDC-0051 v2 instead, which is the historical default.

A CDR file holds eight subdatasets and concentration is not the first of them - band 1 is cdr_seaice_conc_interp_spatial_flag. This reader addresses cdr_seaice_conc by name, so a positional read cannot silently return a flag layer.

Values are sea ice concentration as a fraction (0-1). When setNA = TRUE, any residual flag value (above 1) is masked; open water is a legitimate 0 and is kept.

The projection is taken from the file. The CDR grids are the same 25km polar stereographic grids as NSIDC-0051, and only if the file declares no CRS at all does this reader fall back to EPSG:3976 (south) or EPSG:3413 (north).

Value

SpatRaster with time dimension, or tibble if returnfiles = TRUE.

See Also

read_nsidc_ice_daily for NSIDC-0051 v2, icefiles for the file listing

Examples

## Not run: 
ice <- read_nsidc_cdr_daily()
ice_n <- read_nsidc_cdr_daily("2023-03-15", hemisphere = "north")

## End(Not run)

Read NSIDC daily sea ice concentration

Description

Read NSIDC passive microwave sea ice concentration (25km) for a single hemisphere.

Usage

read_nsidc_ice_daily(
  date,
  hemisphere = c("south", "north"),
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

hemisphere

"south" (default) or "north".

xylim

extent to crop (in native projection coordinates), or NULL.

setNA

logical, mask special values (land, coast, missing) to NA? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Details

Data are returned in the native polar stereographic projection:

  • South: EPSG:3976 (WGS 84 / NSIDC Sea Ice Polar Stereographic South)

  • North: EPSG:3413 (WGS 84 / NSIDC Sea Ice Polar Stereographic North)

Values are sea ice concentration as a fraction (0-1), as the files store them. When setNA = TRUE, any residual flag value (land, coast, missing, polar hole) is masked to NA; open water is a legitimate 0 and is kept.

The NSIDC archive contains some dates with placeholder files (no ice variable). These are automatically filtered out using an internal index of known bad files. When multiple sensor variables exist in a file, the first is used.

For combined hemisphere output or reprojection to a custom grid, use the legacy readice function with hemisphere = "both".

Value

SpatRaster with time dimension, or tibble if returnfiles = TRUE.

See Also

readice for legacy interface with hemisphere = "both" support, read_nsidc_ice_monthly for monthly data

Examples

## Not run: 
# Latest southern hemisphere ice
ice <- read_nsidc_ice_daily()

# Specific date, northern hemisphere
ice_n <- read_nsidc_ice_daily("2023-03-15", hemisphere = "north")

# Multiple dates
ice <- read_nsidc_ice_daily(c("2023-01-15", "2023-06-15"))

# Without NA masking (keeps special values as raw integers)
ice_raw <- read_nsidc_ice_daily("2023-01-15", setNA = FALSE)

## End(Not run)

Read NSIDC monthly sea ice concentration

Description

Read NSIDC passive microwave sea ice concentration (25km) monthly data.

Usage

read_nsidc_ice_monthly(
  date,
  hemisphere = c("south", "north"),
  xylim = NULL,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

hemisphere

"south" (default) or "north".

xylim

extent to crop (in native projection coordinates), or NULL.

setNA

logical, mask special values (land, coast, missing) to NA? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog.

Value

SpatRaster with time dimension, or tibble if returnfiles = TRUE.

See Also

read_nsidc_ice_daily for daily data

Examples

## Not run: 
# Latest monthly ice
ice <- read_nsidc_ice_monthly()

## End(Not run)

Read ocean colour chlorophyll-a (daily)

Description

Read NASA ocean colour chlorophyll-a from L3m (mapped) products. Combines data from SeaWiFS (1997-2010), MODISA (2002+), and VIIRS (2012+) into a continuous time series.

Usage

read_oc_chl_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_oc_chl_8day(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

read_oc_chl_monthly(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = "chlor_a",
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

varname

subdataset to read, default "chlor_a".

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog (from ocfiles()).

Details

Data are 4km global mapped products from NASA Ocean Biology Processing Group. When sensor eras overlap, one observation per date is returned (typically MODISA).

To read from a specific sensor only, use ocfiles() to get the file catalog and pass it via inputfiles.

Value

SpatRaster with time dimension set.

See Also

ocfiles for file catalog, read_oc_chl_8day, read_oc_chl_monthly

Examples

## Not run: 
# Latest chlorophyll
chl <- read_oc_chl_daily()

# Earliest (should be SeaWiFS era)
chl_sw <- read_oc_chl_daily(latest = FALSE)

# Specific sensor only
modis_files <- ocfiles("daily", product = "MODISA", varname = "CHL", type = "L3m")
chl_modis <- read_oc_chl_daily("2020-01-15", inputfiles = modis_files)

## End(Not run)

Read ocean colour PAR (8-day)

Description

Read Photosynthetically Available Radiation from NASA MODISA L3m products.

Usage

read_oc_par_8day(
  date,
  xylim = NULL,
  lon180 = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct).

xylim

extent to crop, anything acceptable to terra::ext().

lon180

logical, use Atlantic-centered longitude? Default TRUE.

latest

if TRUE and date missing, return latest; if FALSE, earliest.

returnfiles

if TRUE, return file catalog instead of data.

...

currently ignored.

inputfiles

optional pre-filtered file catalog (from ocfiles()).

Value

SpatRaster with time dimension set.

See Also

read_oc_chl_daily


Read OISST daily sea surface temperature

Description

Read NOAA Optimum Interpolation Sea Surface Temperature (OISST) v2.1 daily data.

Usage

read_oisst_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = c("sst", "anom", "err", "ice"),
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct). If missing, returns earliest or latest depending on latest argument.

xylim

extent to crop, anything acceptable to terra::ext(). Applied after rotation if lon180 = TRUE.

lon180

logical, convert from Pacific (0,360) to Atlantic (-180,180) view? Default TRUE.

varname

variable to read: one of "sst", "anom", "err", "ice".

latest

if TRUE and date missing, return latest available; if FALSE, return earliest.

returnfiles

if TRUE, return the file catalog instead of reading data.

...

currently ignored.

inputfiles

optionally provide a pre-filtered file catalog (tibble with date and fullname columns).

Details

OISST files contain four variables:

  • sst - sea surface temperature (Celsius)

  • anom - SST anomaly from climatology (Celsius)

  • err - estimated error standard deviation (Celsius)

  • ice - sea ice concentration (percent)

Data are on a global 0.25 degree grid (1440x720). Source files use Pacific-centered longitude (0-360); use lon180 = TRUE (default) to convert to Atlantic-centered (-180 to 180).

Date matching uses a 1.5-day tolerance window - if no file exists within 1.5 days of a requested date, an error is raised.

Value

SpatRaster with time dimension set to file dates, or tibble if returnfiles = TRUE.

See Also

readsst for legacy interface (returns raster objects)

Examples

## Not run: 
# latest SST
sst <- read_oisst_daily()

# specific dates
sst <- read_oisst_daily(c("2023-01-15", "2023-06-15"))

# SST anomaly, cropped to Southern Ocean
anom <- read_oisst_daily("2023-01-15", varname = "anom",
                         xylim = c(-180, 180, -80, -40))

# just get the file list
files <- read_oisst_daily(returnfiles = TRUE)

## End(Not run)

Read OISST monthly sea surface temperature

Description

Read NOAA Optimum Interpolation Sea Surface Temperature (OISST) v2.1 monthly data.

Usage

read_oisst_monthly(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = c("sst", "anom", "err", "ice"),
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (character, Date, or POSIXct). If missing, returns earliest or latest depending on latest argument.

xylim

extent to crop, anything acceptable to terra::ext(). Applied after rotation if lon180 = TRUE.

lon180

logical, convert from Pacific (0,360) to Atlantic (-180,180) view? Default TRUE.

varname

variable to read: one of "sst", "anom", "err", "ice".

latest

if TRUE and date missing, return latest available; if FALSE, return earliest.

returnfiles

if TRUE, return the file catalog instead of reading data.

...

currently ignored.

inputfiles

optionally provide a pre-filtered file catalog (tibble with date and fullname columns).

Details

Monthly files contain the same variables as daily files. Date matching uses a 28-day tolerance window.

Value

SpatRaster with time dimension set to file dates, or tibble if returnfiles = TRUE.

See Also

read_oisst_daily for daily data

Examples

## Not run: 
# latest monthly SST
sst <- read_oisst_monthly()

# specific months
sst <- read_oisst_monthly(c("2023-01-01", "2023-06-01"))

## End(Not run)

REMA tile index

Description

Read the index of Reference Elevation Model of Antarctica (REMA) tiles, as polygon outlines. Use read_topo with one of the 'rema_' data sets to read the elevation data itself.

Usage

read_rema_tiles(...)

Arguments

...

reserved for future use, ignored currently

Value

SpatVector of REMA tile outlines

See Also

read_topo


Read SOSE Southern Ocean State Estimate

Description

Model data read from files managed by sose_monthly_files. Dates are matched to file names by finding the nearest match in time within a short duration. If date is greater than length 1 then the sorted set of unique matches is returned.

Usage

read_sose(
  date,
  time.resolution = c("monthly"),
  varname = "",
  level = 1L,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date to read, the nearest match is used

time.resolution

monthly, the only resolution available

varname

variable to return from the data files, default is whatever first value from sose_monthly_varnames()

level

defaults to 1L - there are 52

setNA

unused, kept for backwards compatibility; terra applies the file's own _FillValue

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

returnfiles

ignore options and just return the file names and dates

...

currently ignored

inputfiles

input the files data base to speed up initialization

Details

This function doesn't support xylim, lon180, or more than one date being read.

Value

SpatRaster, one layer per requested level

Examples

## Not run: 
read_sose(varname = "Uvel", level = 1)
read_sose(varname = "SeaIceArea", level = 1, latest = FALSE)
read_sose(varname = "Chl", level = 10, latest = FALSE)


## End(Not run)

Read topography or bathymetry data

Description

Read data from various topography/bathymetry sources.

Usage

read_topo(
  topo = c("gebco_23", "gebco_21", "gebco_19", "gebco_14", "gebco_08", "etopo1",
    "etopo2", "ibcso", "ibcso_is", "ibcso_bed", "smith_sandwell", "kerguelen",
    "cryosat2", "ramp", "rema_8m", "rema_100m", "rema_200m", "rema_1km", "lake_superior",
    "macrie1100m", "macrie2100m"),
  xylim = NULL,
  lon180 = TRUE,
  polar = FALSE,
  resample = "bilinear",
  returnfiles = FALSE,
  ...
)

read_bathy(
  topo = c("gebco_23", "gebco_21", "gebco_19", "gebco_14", "gebco_08", "etopo1",
    "etopo2", "ibcso", "ibcso_is", "ibcso_bed", "smith_sandwell", "kerguelen",
    "cryosat2", "ramp", "rema_8m", "rema_100m", "rema_200m", "rema_1km", "lake_superior",
    "macrie1100m", "macrie2100m"),
  xylim = NULL,
  lon180 = TRUE,
  polar = FALSE,
  resample = "bilinear",
  returnfiles = FALSE,
  ...
)

readtopo(
  topo = c("gebco_23", "gebco_21", "gebco_19", "gebco_14", "gebco_08", "etopo1",
    "etopo2", "ibcso", "ibcso_is", "ibcso_bed", "smith_sandwell", "kerguelen",
    "cryosat2", "ramp", "rema_8m", "rema_100m", "rema_200m", "rema_1km", "lake_superior",
    "macrie1100m", "macrie2100m"),
  xylim = NULL,
  lon180 = TRUE,
  polar = FALSE,
  resample = "bilinear",
  returnfiles = FALSE,
  ...
)

readbathy(
  topo = c("gebco_23", "gebco_21", "gebco_19", "gebco_14", "gebco_08", "etopo1",
    "etopo2", "ibcso", "ibcso_is", "ibcso_bed", "smith_sandwell", "kerguelen",
    "cryosat2", "ramp", "rema_8m", "rema_100m", "rema_200m", "rema_1km", "lake_superior",
    "macrie1100m", "macrie2100m"),
  xylim = NULL,
  lon180 = TRUE,
  polar = FALSE,
  resample = "bilinear",
  returnfiles = FALSE,
  ...
)

Arguments

topo

character, dataset name (see Details)

xylim

extent to crop, or SpatRaster template for warping. Accepts anything terra::ext() understands: numeric vector c(xmin, xmax, ymin, ymax), SpatExtent, or SpatRaster. If a SpatRaster with CRS is provided, data is warped to match.

lon180

logical, return Atlantic-centered [-180,180] view? Default TRUE.

polar

logical, for IBCSO return polar stereographic version?

resample

character, resampling method for warping (default "bilinear")

returnfiles

logical, return file path instead of data?

...

currently ignored

Details

The following datasets are available via the topo argument:

gebco_23

GEBCO 2023 grid (ice surface), 15 arc-second global

gebco_21

GEBCO 2021 grid

gebco_19

GEBCO 2019 grid

gebco_14

GEBCO 2014 grid

gebco_08

GEBCO 2008 grid, 30 arc-second

etopo1

ETOPO1 1 arc-minute global relief

etopo2

ETOPO2 (historic, deprecated)

ibcso, ibcso_is

IBCSO v2 ice surface, 500m Antarctic

ibcso_bed

IBCSO v2 bedrock

smith_sandwell

Global seafloor from satellite altimetry

kerguelen

Kerguelen Plateau bathymetric grid

cryosat2

CryoSat-2 Antarctic DEM

ramp

RADARSAT Antarctic DEM v2

rema_8m, rema_100m, rema_200m, rema_1km

REMA Antarctic DEMs

lake_superior

Lake Superior bathymetry

macrie1100m, macrie2100m

Macquarie Ridge 100m grids

Value

SpatRaster, or character file path if returnfiles = TRUE

See Also

topofile for file paths only

Examples

## Not run: 
# Read GEBCO 2023
bathy <- read_topo("gebco_23")

# Crop to region
bathy <- read_topo("gebco_23", xylim = c(100, 150, -60, -40))

# Warp to template raster
template <- terra::rast(nrows = 100, ncols = 100,
                        xmin = 100, xmax = 150, ymin = -60, ymax = -40,
                        crs = "EPSG:4326")
bathy <- read_topo("gebco_23", xylim = template)

## End(Not run)

Read AMPS sea ice cover

Description

The ICEC field of the AMPS d1 forecast files, as a fraction. This reads from the 00UT and 12UT analysis files only, which is what amps_d1_icefiles selects: the later forecast hours of the pre-2018 files carry no surface fields at all.

Usage

readamps_d1ice(
  date,
  time.resolution = "12hourly",
  xylim = NULL,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

ignored, kept for backward compatibility

xylim

spatial extents to crop from source data, anything acceptable to ext

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

returnfiles

ignore options and just return the file names and dates

...

passed to writeRaster if filename is given

inputfiles

input the files data base to speed up initialization

Value

SpatRaster, or the file catalogue if returnfiles = TRUE

See Also

readamps_d1wind for the wind fields on the same grid

Examples

## Not run: 
terra::plot(readamps_d1ice(latest = TRUE))

## End(Not run)

read AMPS data

Description

Read from The Antarctic Mesoscale Prediction System (AMPS) files. readamps_d1wind reads the "d1" level wind (defaults to 1).

Usage

readamps_d1wind(
  date,
  time.resolution = "4hourly",
  xylim = NULL,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  level = 1,
  ...,
  inputfiles = NULL
)

readamps_d2wind(
  date,
  time.resolution = "4hourly",
  xylim = NULL,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  level = 1,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

ignored, kept for backward compatibility

xylim

spatial extents to crop from source data, anything acceptable to ext

magonly

return wind magnitude only

dironly

return wind direction only

uonly

return the u component only

vonly

return the v component only

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

returnfiles

ignore options and just return the file names and dates

level

1 for the 10 m wind, 2 onwards for the isobaric levels

...

passed to writeRaster if filename is given

inputfiles

input the files data base to speed up initialization

Details

readamps_d2wind reads the same fields from the finer "d2" domain.

level 1 is the 10 m wind; 2 onwards are the isobaric levels in file order, starting at 1000 hPa and working up. How many there are varies with the file, and an out of range level is an error rather than a silent substitution.

See amps_metadata for a description of the bands of one 2015-era file. It is a snapshot, not an index: the band layout has changed three times since, so these readers find their bands by name in the file at hand rather than by position in that table.

Data http://www2.mmm.ucar.edu/rt/amps/wrf_grib/, and contain gridded forecast data from the AMPS-WRF model. The 'd1' (domain 1) files were on a 30km grid and are now 24km, while the 'd2' (domain 2) files were 10km and are now 8km; the change happened around 2018-11-16 and the grid comes from each file. The grid domains are shown at http://polarmet.osu.edu/AMPS/ - d2 extends out to southern Australia and the tip of South America, and d1 covers just Antarctica (including Davis) and parts of the Southern Ocean. There are two forecast cycles, starting at 00UT and 12UT daily. Forecasts are for +00, +03, +06, +09, +12 and +15 hours. These steps can be used to see how the wind field is forecast as changing, and to obtain two different data sets each 3 hour timestep (e.g. the +15h forecast for the 00UT run is at the same time as the +03h forecast from the 12UT run). The 00UT and 12UT runs of the pre-2018 files are the only ones that carry the surface fields, so readamps_d1ice reads from those alone.

Value

SpatRaster, or the file catalogue if returnfiles = TRUE

Examples

## Not run: 
af <- amps_d1files()
w <- readamps_d1wind(latest = TRUE, inputfiles = af)
vlen <- function(a, b) sqrt(a * a + b * b)
terra::plot(vlen(w[[1]], w[[2]]))

## the 850 hPa wind rather than the 10 m wind
readamps_d1wind(latest = TRUE, inputfiles = af, level = 8)

## End(Not run)

Read 'cafe' MODIS monthly data

Description

I don't remember what these are but they were at https://orca.science.oregonstate.edu/

Usage

readcafe(
  date,
  time.resolution = c("monthly"),
  xylim = NULL,
  lon180 = TRUE,
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read,

time.resolution

time resoution data to read, daily or monthly

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

lon180

defaults to TRUE, to "rotate" Pacific view [0, 360] data to Atlantic view [-180, 180]

setNA

mask out land values (only applies to monthly time.resolution)

latest

if TRUE (and date not supplied) return the latest time available

returnfiles

ignore options and just return the file names and dates

...

passed to writeRaster, primarily for filename

inputfiles

input the files data base to speed up initialization

Details

Files are found with raadfiles::cafe_monthly_files().

Examples

readcafe(date = "2010-01-15")

Read Chlorophyll-a, NASA algorithm

Description

Ocean colour Chlorophyll-a from the NASA L3m (mapped) products, across the SeaWiFS, MODISA and VIIRS eras. This is the legacy front door onto read_oc_chl_daily; use that directly, or read_oc_chl_8day and read_oc_chl_monthly, to pin a particular temporal resolution.

Usage

readchla(
  date,
  product = c("any", "MODISA", "SeaWiFS", "VIIRS"),
  xylim = NULL,
  algorithm = c("nasa"),
  latest = TRUE,
  grid = NULL,
  ...,
  returnfiles = FALSE,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

product

sensor to read from, or "any" to draw on all three eras

xylim

spatial extents to crop from source data, anything acceptable to ext, ignored if grid is provided

algorithm

nasa only

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

grid

template SpatRaster to resample the output onto

...

currently ignored

returnfiles

ignore options and just return the file names and dates

inputfiles

input the files data base to speed up initialization

Details

One layer is returned per date. Earlier versions of this function averaged every requested date down into a single layer; to get that, average the result yourself with terra::mean() or terra::app().

Value

SpatRaster

See Also

read_oc_chl_daily for the reader this calls, ocfiles for the repository of data files

Examples

## Not run: 
d <- readchla(c("2003-01-01", "2003-06-01"),
         xylim = terra::ext(100, 150, -70, -30))

## End(Not run)

Read ocean current data

Description

readcurr picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see the CMEMS current readers:

Usage

readcurr(
  date,
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

readcurrents(
  date,
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

xylim

spatial extents to crop

lon180

if TRUE (default), use Atlantic-centered longitude

magonly

return current speed only

dironly

return current direction only

uonly

return U component only

vonly

return V component only

latest

if TRUE and date missing, return latest

returnfiles

if TRUE, return file catalog

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

Value

SpatRaster, or tibble if returnfiles = TRUE

See Also

read_cmems_ugos_daily, read_cmems_vgos_daily, read_cmems_current_speed_daily, read_cmems_current_direction_daily


Read data from polar climatological and other summary environmental data

Description

Derived data are read from files managed by derivaadcfiles.

Usage

readderivaadc(products, xylim = NULL, returnfiles = FALSE, ...)

Arguments

products

choice of products, see derivaadcproducts for available products

xylim

spatial extents to crop from source data, can be anything accepted by ext

returnfiles

ignore options and just return the file names

...

passed on, primarily for filename

Value

SpatRaster

References

http://data.aad.gov.au/aadc/metadata/metadata.cfm?entry_id=Polar_Environmental_Data

See Also

derivaadcfiles for details on the repository of data files

Examples

## Not run: 
prods <- c("bathymetry","chl_summer_climatology")
x <- readderivaadc(prods)

## End(Not run)

Read data from derived sea ice data products.

Description

Derived sea ice data is read from files managed by derivicefiles.

Usage

readderivice(
  date,
  time.resolution = c("daily"),
  product = c("time_since_melt"),
  xylim = NULL,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read, see Details

time.resolution

time resoution data to read, daily or monthly

product

choice of sea ice product, see Details

xylim

spatial extents to crop from source data, can be anything accepted by ext

latest

if TRUE and date input missing, return the latest time available, otherwise the earliest

returnfiles

ignore options and just return the file names and dates

...

passed on, primarily for filename

inputfiles

input the file set to avoid rescanning that (for extract point-in-time)

Details

Currently available products are

Dates are matched to file names by finding the nearest match in time within a short duration. If date is greater than length 1 then the sorted set of unique matches is returned.

time_since_melt

32767 (treated as missing data)

32766 = land

32765 = open-ocean zone

-32768 = ice that hasn't melted during the data period

In terms of missing data 32767, in the nc file, so should be NA once read into R): these are either open water in the sea ice zone that hasn't re-frozen during the data period, or missing sea ice data that couldn't be interpolated.

Value

SpatRaster

See Also

derivicefiles for details on the repository of data files


Fast ice data

Description

Fast ice data

Usage

readfastice(
  date,
  product = c("circum_fast_ice"),
  xylim = NULL,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates to read (can be character, POSIXt, or Date)

product

'circum_fast_ice' or 'binary_fast_ice'

xylim

extent in native space of the grid

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

returnfiles

return the file details only

...

passed on, primarily for filename

inputfiles

input the files data base to speed up initialization

time.resolution

fixed, the underlying time step is 15 days

Details

High-resolution mapping of circum-Antarctic landfast sea ice distribution, 2000-2018.

Fast ice data on original polar stereographic grid, the product "circum_fast_ice" is 1000m resolution published in Alex Fraser et al. (2020).

Value

SpatRaster, see Details

Circumpolar product from 2020

Classified surface type:

  • 0: pack ice or ocean

  • 1: continent

  • 2: islands

  • 3: ice shelf

  • 4: fast ice

  • 5: manual fast ice edge

  • 6: auto fast ice edge

Examples

## read a particular date, it's circumpolar grid with 7 discrete numerc classes
fice <- readfastice("2015-10-01")
## hone in on Davis
ex <- c(1742836L, 3315135L, 129376L, 1136611L)
davis_ice <- terra::crop(fice, terra::ext(1742836, 3315135, 129376, 1136611))
plot(davis_ice >= 4) #, col = c("brown", "white", grey(c(0.2, 0.5, 0.8))), breaks = c(0, 1, 3, 4, 5, 6))

## compare 5 years change
davis_ice2 <- terra::crop(readfastice("2010-10-01"), terra::ext(ex))
par(mfrow = c(2, 1))
plot(davis_ice >= 4)
plot(davis_ice2 >= 4)

Read data from the Sokolov/Rintoul Southern Ocean fronts analysis.

Description

Sokolov Rintoul

Usage

readfronts(
  date,
  time.resolution = c("weekly"),
  product = c("sokolov"),
  xylim = NULL,
  lon180 = TRUE,
  setNA = FALSE,
  trim = TRUE,
  returnfiles = FALSE,
  RAT = TRUE,
  ...
)

Arguments

date

date or dates of data to read, see Details

time.resolution

time resoution data to read, daily or monthly

product

choice of product, see Details

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

lon180

if TRUE, data originally in Pacific view will be returned in Atlantic view (-180:180)

setNA

is TRUE NaN values are replaced with NA

trim

if TRUE the map is cropped to no contiguous margins of missing data

returnfiles

ignore options and just return the file names and dates

RAT

if TRUE data is returned as a categorical raster with the region names as its levels, see levels

...

reserved for future use, currently ignored

Value

SpatRaster

Examples

## Not run: 
b <- readfronts(c("1993-01-01", "2005-01-02"), lon180 = FALSE)

## End(Not run)

Backward-in-time Finite-Size Lyapunov Exponents

Description

Daily files This dataset contains Backward-in-time FSLE product deduced from DT merged Global Ocean Gridded Absolute Geostrophic Velocities SSALTO/Duacs L4 product (version 2018).

Usage

readfsle(
  date,
  time.resolution = c("daily"),
  xylim = NULL,
  latest = TRUE,
  varname = c("fsle_max", "theta_max"),
  returnfiles = FALSE,
  verbose = TRUE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read, see Details

time.resolution

time resolution to read (only daily)

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

latest

if TRUE and input date is missing return the latest time available, otherwise the earliest

varname

either fsle_max or 'theta_max“

returnfiles

ignore options and just return the file names and dates

verbose

print messages on progress etc.

...

filename to write the result to, otherwise ignored

inputfiles

input the files data base to speed up initialization

Value

SpatRaster, or a data.frame of files if returnfiles = TRUE


Read GHRSST

Description

SST in Kelvin

Usage

readghrsst(
  date,
  time.resolution = c("daily"),
  xylim = NULL,
  lon180 = TRUE,
  varname = c("analysed_sst", "analysis_error", "mask", "sea_ice_fraction"),
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

datetime

time.resolution

daily

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

lon180

currently ignored

varname

one of "analysed_sst", "analysis_error", "mask", "sea_ice_fraction"

setNA

ignored

latest

if TRUE (and date not supplied) return the latest time available

returnfiles

ignore options and just return the file names and dates

...

arguments passed to raster brick

inputfiles

input the files data base to speed up initialization

Value

SpatRaster, or a data.frame of files if returnfiles = TRUE


Read sea ice concentration data

Description

readice picks a sensible default and returns a terra SpatRaster. That default is now the NOAA/NSIDC Climate Data Record (G02202 V6), read by read_nsidc_cdr_daily. For the historical defaults pinned explicitly, see read_nsidc_ice_daily and read_nsidc_ice_monthly, which stay on NSIDC-0051 v2.

The hemisphere = "both" functionality (warping both hemispheres to a common grid) is only available through this function.

Usage

readice(
  date,
  time.resolution = "daily",
  product = c("cdr", "nsidc"),
  hemisphere = c("south", "north", "both"),
  xylim = NULL,
  setNA = TRUE,
  rescale = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL,
  resample = "bilinear"
)

readice_daily(
  date,
  time.resolution = "daily",
  product = c("cdr", "nsidc"),
  hemisphere = c("south", "north", "both"),
  xylim = NULL,
  setNA = TRUE,
  rescale = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL,
  resample = "bilinear"
)

readice_monthly(
  date,
  time.resolution = "monthly",
  product = "nsidc",
  hemisphere = c("south", "north"),
  xylim = NULL,
  setNA = TRUE,
  rescale = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

deprecated, use readice_daily or readice_monthly

product

"cdr" (default) for the Climate Data Record, or "nsidc" for NSIDC-0051 v2

hemisphere

"south", "north", or "both"

xylim

spatial extents to crop, or a SpatRaster (or Raster*) template to warp onto when hemisphere = "both"

setNA

mask special values as NA

rescale

ignored (v2 data is already scaled)

latest

if TRUE and date missing, return latest available

returnfiles

if TRUE, return file catalog

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

resample

resampling method for warper (when hemisphere = "both")

Value

SpatRaster, or tibble if returnfiles = TRUE

See Also

read_nsidc_cdr_daily for the Climate Data Record reader read_nsidc_ice_daily for the NSIDC-0051 v2 daily reader read_nsidc_ice_monthly for the monthly reader


Area of pixels in sea ice

Description

Read the NSIDC pixel-area files for either hemisphere. Only 25km product is supported. Tool name "psn25area_v3.dat and pss25area_v3.dat": http://nsidc.org/data/polar-stereo/tools_geo_pixel.html#pixel_area.

Usage

readice_area(product = "nsidc", hemisphere = "south", ...)

Arguments

product

"nsidc" the 25km NSIDC passive microwave

hemisphere

south (default) or north

...

ignored

Value

SpatRaster with the area of the cells in m^2

See Also

readice

Examples

readice_area()
readice_area(hemisphere = "north")

MODIS Rapid Response images

Description

Read MODIS Rapid Response RGB images

Usage

readrapid_response(
  date,
  product = c("aqua", "terra"),
  latest = TRUE,
  returnfiles = FALSE,
  ...
)

Arguments

date

date of image to load

latest

if TRUE and date input is missing return the latest time available, otherwise the earliest

returnfiles

return just the list of files

...

filename to write the result to, otherwise ignored

Details

MODIS Rapid Response, Antarctica

Value

SpatRaster


Read SMAP sea surface salinity data

Description

SMAP surface salinity data read from files managed by salfiles.

Usage

readsal(
  date,
  time.resolution = c("daily"),
  xylim = NULL,
  lon180 = TRUE,
  varname = c("sss_smap", "nobs", "sss_ref", "gland", "gice", "surtep"),
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read,

time.resolution

time resoution data to read, daily or monthly

xylim

spatial extents to crop from source data, can be anything accepted by ext, see Details

lon180

defaults to TRUE, to "rotate" Pacific view [0, 360] data to Atlantic view [-180, 180]

varname

variable to return from the data files, default is "sss_smap", also available is "nobs", "sss_ref", "gland", "gice", "surtep"

setNA

mask out land values (only applies to monthly time.resolution)

latest

if TRUE (and date not supplied) return the latest time available

returnfiles

ignore options and just return the file names and dates

...

passed to writeRaster, primarily for filename

inputfiles

input the files data base to speed up initialization

readall

FALSE by default

Value

SpatRaster, or a data.frame of files if returnfiles = TRUE


Read sea surface height data

Description

readssh picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see read_cmems_adt_daily and read_cmems_sla_daily.

Usage

readssh(
  date,
  time.resolution = c("daily"),
  xylim = NULL,
  lon180 = TRUE,
  ssha = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  verbose = TRUE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

time resolution (only "daily" supported)

xylim

spatial extents to crop

lon180

if TRUE (default), use Atlantic-centered longitude

ssha

if TRUE, return sea level anomaly; if FALSE (default), return ADT

latest

if TRUE and date missing, return latest

returnfiles

if TRUE, return file catalog

verbose

ignored (for backward compatibility)

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

Value

SpatRaster, or tibble if returnfiles = TRUE

See Also

read_cmems_adt_daily, read_cmems_sla_daily


Read sea surface temperature data

Description

readsst picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see read_oisst_daily and read_oisst_monthly.

Usage

readsst(
  date,
  time.resolution = c("daily", "monthly"),
  xylim = NULL,
  lon180 = TRUE,
  varname = c("sst", "anom", "err", "ice"),
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

readsst_daily(
  date,
  xylim = NULL,
  lon180 = TRUE,
  varname = c("sst", "anom", "err", "ice"),
  setNA = TRUE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

time resolution: "daily" or "monthly"

xylim

spatial extents to crop from source data

lon180

if TRUE (default), convert Pacific (0,360) to Atlantic (-180,180) view

varname

variable to read: "sst", "anom", "err", or "ice"

setNA

mask out land values (ignored in new implementation, kept for API compatibility

latest

if TRUE and date missing, return latest available

returnfiles

if TRUE, return the file catalog instead of data

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

Value

SpatRaster, or tibble if returnfiles = TRUE

See Also

read_oisst_daily for the modern terra-based daily reader read_oisst_monthly for the modern terra-based monthly reader

Examples

## Not run: 
# sensible default
sst <- readsst("2023-01-15")
class(sst)  # SpatRaster, one layer

# historical default pinned explicitly
sst <- read_oisst_daily("2023-01-15")
class(sst)  # SpatRaster

## End(Not run)

Read wind data

Description

readwind picks a sensible default and returns a terra SpatRaster. For the historical defaults pinned explicitly, see read_ncep2_wind_6hourly.

Usage

readwind(
  date,
  time.resolution = c("6hourly"),
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read

time.resolution

time resolution, currently only "6hourly"

xylim

spatial extents to crop

lon180

if TRUE (default), use Atlantic-centered longitude

magonly

return wind speed only

dironly

return wind direction only

uonly

return U component only

vonly

return V component only

latest

if TRUE and date missing, return latest

returnfiles

if TRUE, return file catalog

...

passed to underlying reader

inputfiles

optional pre-filtered file catalog

Value

SpatRaster, or tibble if returnfiles = TRUE

See Also

read_ncep2_wind_6hourly for modern terra-based reader


SMAP sea surface temperature files

Description

Load file names and dates of SMAP sea surface salinity

Usage

salfiles(time.resolution = c("daily"), ...)

Arguments

time.resolution

time resolution read

...

reserved for future use, currently ignored

Details

A data frame of file names and dates.

Only a short period of daily data is available, from '2015-03-27' to '2018-10-21'.

Value

data.frame of file names and dates


Set the file system locations where data are stored

Description

This is a convenience wrapper around the corresponding admin functions in the raadfiles package, so that most users will not need to use those functions directly. This function tells raadtools where to look for its data files, (by default) will build the necessary file list cache if it does not exist, and loads that cache into memory so that raadtools can use it.

Usage

set_data_roots(..., build_cache_if_missing = TRUE, refresh_cache = FALSE)

get_data_roots()

Arguments

...

strings: one or more paths to directories containing data

build_cache_if_missing

logical: raadtools maintains a cache that lists all of files in each data collection. If build_cache_if_missing is TRUE, a cache will be built if it does not exist

refresh_cache

logical: for each path, should the file collection be re-scanned and the cache rebuilt? (May be slow)

Value

TRUE (invisibly) on success

Examples

## Not run: 
## assume that we have downloaded some data files to c:/my/data
library(raadtools)
set_data_roots("c:/my/data")
## see the README/vignette for more detail

## End(Not run)

SOSE varnames

Description

Available variable names from SOSE.

Usage

sose_monthly_varnames(iteration = "")

Arguments

iteration

SOSE iteration, passed to raadfiles::sose_monthly_files()

Details

These varnames can be used in read_sose(varname = ).

They come from the file names and are what selects a file. The variable inside the file may be spelt differently - the SeaIceArea files hold a variable called SIarea - so read_sose() works that out from the file rather than from the name.

Value

character vector

Examples

sose_monthly_varnames()

AVISO sea surface height / anomaly files

Description

Load file names and dates of AVISO SSH/SSHA data

Usage

sshfiles(time.resolution = c("daily"), ...)

Arguments

time.resolution

set to daily only

...

reserved for future use, currently ignored

Details

A data.frame of file names and dates

Value

data.frame of file names and dates

See Also

readssh


SST colours

Description

SST colours

Usage

sst.pal(x, palette = FALSE, alpha = 1)

Arguments

x

a vector of data values or a single number

palette

logical, if TRUE return a list with matching colours and values

alpha

value in 0,1 to specify opacity

Value

colours, palette, or function, see Details

References

Derived from "http://oceancolor.gsfc.nasa.gov/DOCS/palette_sst.txt.


OISST sea surface temperature files

Description

Load file names and dates of OISST sea surface temperature data

Usage

sstfiles(time.resolution = c("daily", "monthly"), ...)

Arguments

time.resolution

time resolution read

...

reserved for future use, currently ignored

Details

A data frame of file names and datres

Value

data.frame of file names and dates


Stations locations

Description

In polar stereographic, with longitude and latitude and name as attributes.

Details

Obtained with antanym

Examples

plot(readice())
plot(stations, add = TRUE)

Read surface currents as table

Description

Read meridional and zonal components of surface currents (m/s) from altimetry products. Input is optional, with date and xylim. As with the grid reading functions read_ugos_daily and read_vgos_daily this by default will return the latest data available and for the entire world.

Usage

table_uvgos(
  date,
  xylim = NULL,
  ...,
  xy = TRUE,
  cell = FALSE,
  na.rm = TRUE,
  latest = TRUE,
  res = NULL
)

Arguments

date

dates to read

xylim

extent of data to read

...

arguments passed to read functions (only lon180 relevant)

xy

include coordinates of cell in the output, TRUE by default

cell

include cell index in the output, FALSE by default

na.rm

by default missing values are removed, set to FALSE to keep all

Details

Please note that the coordinates are in longitude latitude, but the velocity components are in m/s. You cannot meaningfully transform the x,y coordinates and use the velocity components without taking into account rotation in the transformation (we might write some helpers for this ...).

Argument lon180 may be used to specify Pacific or Atlantic orientation.

Value

data frame of u, v, x,y (longitude,latitude), cell, and date

Examples

uv <- table_uvgos("2001-01-01", xylim = terra::ext(60, 120, -60, -10))
plot(range(uv$x), range(uv$y), type = "n", asp = 1.1)
scal <- function(x) (x - min(x, na.rm = TRUE))/diff(range(x, na.rm = TRUE))
nn <- 56
arrows(uv$x, uv$y, uv$x + uv$u, uv$y + uv$v, col = grey.colors(nn)[scal(sqrt(uv$u^2 + uv$v^2)) * (nn-1) + 1], length = 0)

Stable conversion to POSIXct from character and Date

Description

Conversion to POSIXct ensuring no local time zone applied. Currently supported is character, Date and anything understood by as.POSIXct.

Usage

timedateFrom(x, ...)

Arguments

x

input date-time stamp, character, Date or other supported type.

...

ignored

Value

the vector x converted (if necessary) to POSIXct


Find topography data files

Description

Return the full path, or GDAL data source name, for a topography or bathymetry data set. Use read_topo to read the data itself.

Usage

topofile(
  topo = c("gebco_23", "gebco_08", "ibcso", "etopo1", "etopo2", "kerguelen",
    "smith_sandwell", "gebco_14", "macrie1100m", "macrie2100m", "cryosat2",
    "lake_superior", "ramp", "ibcso_is", "ibcso_bed", "rema_1km", "rema_200m",
    "rema_100m", "rema_8m", "gebco_19", "gebco_21"),
  polar = FALSE,
  lon180 = TRUE,
  ...
)

Arguments

topo

Data source, see read_topo.

polar

Flag for returning the polar version of the IBCSO data.

lon180

Flag for returning data in Atlantic [-180, 180] rather than Pacific [0, 360] view.

...

reserved for future use, ignored currently

Details

The available data sets, and what each one is, are listed in the Details section of read_topo.

Value

character string of the full path to a file name

See Also

read_topo to read the data


Files containing NCEP2 wind vector data

Description

NCEP2 wind files

Usage

windfiles(data.source = "", time.resolution = c("6hourly"), ...)

Arguments

data.source

ignored, reserved for future use

time.resolution

time resolution data to read, 6hourly only for now

...

reserved for future use, currently ignored

Details

Files containing NCEP2 wind vector data

Value

data.frame of file names and dates