get_depths {CCAMLRGIS}R Documentation

Get depths of locations from bathymetry raster

Description

Given a bathymetry raster and an input dataframe of point locations (given in decimal degrees), computes the depths at these locations using bilinear interpolation (using extract). Optionally can also compute the horizontal distance of locations to chosen isobaths.

Usage

get_depths(
  Input,
  Bathy,
  d = 10000,
  Isobaths = NA,
  IsoLocs = FALSE,
  ShowProgress = FALSE,
  NamesIn = NULL
)

Arguments

Input

dataframe with, at least, Latitudes and Longitudes. If NamesIn is not provided, the columns in the Input must be in the following order:

Latitude, Longitude, Variable 1, Variable 2, ... Variable x

Bathy

bathymetry raster with the appropriate projection, such as this one. It is recommended to use a raster of higher resolution than SmallBathy.

d

distance in meters, used to group locations by distance and speed up computations (by cutting the bathymetry raster into small pieces matching the extent of grouped locations). Lower values make computations faster but at the risk of not finding distances to isobaths (when desired).

Isobaths

Depths to which the horizontal distances to locations are computed, if required.

IsoLocs

If TRUE, the locations on the Iosbaths that are closest to the locations given in the Input are added to the exported dataframe.

ShowProgress

if set to TRUE, a progress bar is shown (get_depths may take a while).

NamesIn

character vector of length 2 specifying the column names of Latitude and Longitude fields in the Input. Latitudes name must be given first, e.g.:

NamesIn=c('MyLatitudes','MyLongitudes').

Value

dataframe with the same structure as the Input with additional columns, where 'x' and 'y' are the projected locations, 'd' is the depth, 'D_iso', 'X_iso' and 'Y_iso' are the horizontal distances and closest point location on 'Isobaths'. All units are in meters.

See Also

SmallBathy, create_Points, create_Stations, extract.

Examples




#Generate a dataframe
MyData=data.frame(Lat=PointData$Lat,
Lon=PointData$Lon,
Catch=PointData$Catch)

#Example 1: get depths of locations
MyDataD=get_depths(Input=MyData,Bathy=SmallBathy)
#View(MyDataD)
plot(MyDataD$d,MyDataD$Catch,xlab='Depth',ylab='Catch',pch=21,bg='blue') #Plot of catch vs depth

#Example 2: get depths of locations and distance to isobath -3000m

MyDataD=get_depths(Input=MyData,Bathy=SmallBathy,
        Isobaths=-3000,IsoLocs=TRUE,d=200000,ShowProgress=TRUE)
plot(MyDataD$x,MyDataD$y,pch=21,bg='green')
raster::contour(SmallBathy,levels=-3000,add=TRUE,col='blue',maxpixels=10000000)
segments(x0=MyDataD$x,
         y0=MyDataD$y,
         x1=MyDataD$X_3000,
         y1=MyDataD$Y_3000,col='red')





[Package CCAMLRGIS version 3.0.7 Index]