Get raster of interpolated values from CalCOFI API

get_raster(
  variable = "ctdcast_bottle.t_deg_c",
  cruise_id = "1949-03-01-C-31CR",
  depth_m_min = NULL,
  depth_m_max = NULL,
  out_tif
)

Arguments

variable

Variable to fetch from the CalCOFI API. One of table_field values from get_variables(). Default is "ctdcast_bottle.t_deg_c".

cruise_id

Cruise identifier. One of cruise_id values from get_cruises(). Default is the first cruise "1949-03-01-C-31CR".

depth_m_min

Minimum depth range in meters, e.g. 0. Default is NULL, as in not filtered.

depth_m_max

Maximum depth range in meters, e.g. 5351. Default is NULL, as in not filtered.

out_tif

Output path to write raster (*.tif)

Value

path to output raster in GeoTIFF format (*.tif)

Examples

out_tif <- tempfile(fileext=".tif")
get_raster(
  variable = "ctdcast_bottle.t_deg_c",
  cruise_id = "1949-03-01-C-3d1CR",
  depth_m_min = 0, depth_m_max = 200,
  out_tif = out_tif)
#> Error in req_perform(.) : HTTP 500 Internal Server Error.
#> Error in last_response() %>% resp_body_json() %>% .$message %>% stop(): Error in (function (variable = "ctd_bottles.t_degc", cruise_id = "2020-01-05-C-33RL", : nrow(v) == 1 is not TRUE
r <- raster::raster(out_tif)
#> Warning: /var/folders/sl/7s3zmk1129jcrgsn1c4hcs2r0000gn/T//RtmpBSt1sc/file23ca7470f5d3.tif: No such file or directory (GDAL error 4)
#> Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer",     ...): Cannot create a RasterLayer object from this file. (file does not exist)
raster::plot(r)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'r' not found
unlink(out_tif)