get_depths {CCAMLRGIS}  R Documentation 
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.
get_depths( Input, Bathy, d = 10000, Isobaths = NA, IsoLocs = FALSE, ShowProgress = FALSE, NamesIn = NULL )
Input 
dataframe with, at least, Latitudes and Longitudes.
If Latitude, Longitude, Variable 1, Variable 2, ... Variable x 
Bathy 
bathymetry raster with the appropriate 
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 
ShowProgress 
if set to 
NamesIn 
character vector of length 2 specifying the column names of Latitude and Longitude fields in
the

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.
SmallBathy
, create_Points
, create_Stations
, extract
.
#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')