create_Stations: Create Stations

View source: R/create.R

create_StationsR Documentation

Create Stations

Description

Create random point locations inside a polygon and within bathymetry strata constraints. A distance constraint between stations may also be used if desired.

Usage

create_Stations(
  Poly,
  Bathy,
  Depths,
  N = NA,
  Nauto = NA,
  dist = NA,
  Buf = 1000,
  ShowProgress = FALSE
)

Arguments

Poly

single polygon inside which stations will be generated. May be created using create_Polys.

Bathy

bathymetry raster with the appropriate projection, such as this one.

Depths

numeric, vector of depths. For example, if the depth strata required are 600 to 1000 and 1000 to 2000, Depths=c(-600,-1000,-2000).

N

numeric, vector of number of stations required in each depth strata, therefore length(N) must equal length(Depths)-1.

Nauto

numeric, instead of specifying N, a number of stations proportional to the areas of the depth strata may be created. Nauto is the maximum number of stations required in any depth stratum.

dist

numeric, if desired, a distance constraint in nautical miles may be applied. For example, if dist=2, stations will be at least 2 nautical miles apart.

Buf

numeric, distance in meters from isobaths. Useful to avoid stations falling on strata boundaries.

ShowProgress

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

Value

Spatial object in your environment. Data within the resulting object contains the strata and stations locations in both projected space ("x" and "y") and decimal degrees of Latitude/Longitude.

To see the data contained in your spatial object, type: View(MyStations).

See Also

create_Polys, SmallBathy.

Examples



# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#22-create-stations

#First, create a polygon within which stations will be created
MyPoly=create_Polys(
 data.frame(Name="mypol",
            Latitude=c(-75,-75,-70,-70),
            Longitude=c(-170,-180,-180,-170))
 ,Densify=TRUE)

par(mai=c(0,0,0,0))
plot(st_geometry(Coast[Coast$ID=='88.1',]),col='grey')
plot(st_geometry(MyPoly),col='green',add=TRUE)
text(MyPoly$Labx,MyPoly$Laby,MyPoly$ID)

#Create a set numbers of stations, without distance constraint:
library(terra)
#optional: crop your bathymetry raster to match the extent of your polygon
BathyCroped=crop(SmallBathy(),ext(MyPoly))

#Create stations
MyStations=create_Stations(MyPoly,BathyCroped,Depths=c(-2000,-1500,-1000,-550),N=c(20,15,10))

#add custom colors to the bathymetry to indicate the strata of interest
MyCols=add_col(var=c(-10000,10000),cuts=c(-2000,-1500,-1000,-550),cols=c('blue','cyan'))
plot(BathyCroped,breaks=MyCols$cuts,col=MyCols$cols,legend=FALSE,axes=FALSE)
add_Cscale(height=90,fontsize=0.75,width=16,lwd=0.5,
offset=-130,cuts=MyCols$cuts,cols=MyCols$cols)
plot(st_geometry(MyPoly),add=TRUE,border='red',lwd=2,xpd=TRUE)
plot(st_geometry(MyStations),add=TRUE,col='orange',cex=0.75,lwd=1.5,pch=3)





CCAMLRGIS documentation built on Sept. 27, 2023, 9:09 a.m.