Map raster of interpolated oceanographic variable for a cruise.

map_raster(r, legend_title = "Temperature (ºC)")

Arguments

r

raster of type raster::raster()

legend_title

title for legend of variable mapped

Value

interactive plot of leaflet::leaflet()

Examples

(r_tif <- tempfile(fileext=".tif"))
#> [1] "/var/folders/sl/7s3zmk1129jcrgsn1c4hcs2r0000gn/T//RtmpBWGgR6/file4ed0701bbaf2.tif"

# use second variable from previously fetched v
c(v$table_field[2], v$plot_label[2])
#> Error in eval(expr, envir, enclos): object 'v' not found

# fetch interpolated raster from CalCOFI API
get_raster(
  variable = v$table_field[2],
  cruise_id = "2020-01-05-C-33RL",
  depth_m_min = 0, depth_m_max = 200,
  out_tif = r_tif)
#> Error in eval(expr, envir, enclos) : object 'v' not found
#> Error in check_content_type(resp, types = "application/json", suffix = "+json",     check_type = check_type): Unexpected content type 'text/csv'
#> Expecting 'application/json'
#> Or suffix '+json'
#>  Override check with `check_type = FALSE`

r <- raster::raster(r_tif)
#> Warning: /var/folders/sl/7s3zmk1129jcrgsn1c4hcs2r0000gn/T//RtmpBWGgR6/file4ed0701bbaf2.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)

# plot raster
map_raster(r, v$plot_label[2])
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'extent': error in evaluating the argument 'x' in selecting a method for function 'raster': object 'r' not found