create_Stations {CCAMLRGIS}R 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

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

N

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

Nauto

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

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

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

ShowProgress

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 degrees of Latitude/Longitude.

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

See Also

create_Polys, SmallBathy, add_RefGrid.

Examples




#First, create a polygon within which stations will be created

MyPolys=create_Polys(Input=PolyData,Densify=TRUE)
plot(MyPolys)
text(MyPolys$Labx,MyPolys$Laby,MyPolys$ID)
#Subsample MyPolys to only keep the polygon with ID 'one'
MyPoly=MyPolys[MyPolys$ID=='one',]
plot(MyPoly,col='green',add=TRUE)

#Second (optional), crop your bathymetry raster to match the extent of your polygon

BathyCroped=raster::crop(SmallBathy,MyPoly)


#Example 1: Set numbers of stations, no distance constraint

MyStations=create_Stations(Poly=MyPoly,
           Bathy=BathyCroped,Depths=c(-550,-1000,-1500,-2000),N=c(20,15,10))
Mypar=par(mai=c(0,0,0,2)) #Figure margins as c(bottom, left, top, right)
plot(BathyCroped,breaks=Depth_cuts, col=Depth_cols, legend=FALSE,axes=FALSE,box=FALSE)
add_Cscale(offset = 50,height = 90,fontsize = 0.8,width=25)
plot(MyPoly,add=TRUE,border='red',lwd=2)
raster::contour(BathyCroped,levels=c(-550,-1000,-1500,-2000),add=TRUE)
plot(MyStations,add=TRUE,col='orange')
par(Mypar)

#Example 2: Set numbers of stations, with distance constraint
 
MyStations=create_Stations(Poly=MyPoly,
           Bathy=BathyCroped,Depths=c(-550,-1000,-1500,-2000),N=c(20,15,10),dist=10)
Mypar=par(mai=c(0,0,0,2)) #Figure margins as c(bottom, left, top, right)
plot(BathyCroped,breaks=Depth_cuts, col=Depth_cols, legend=FALSE,axes=FALSE,box=FALSE)
add_Cscale(offset = 50,height = 90,fontsize = 0.8,width=25)
plot(MyPoly,add=TRUE,border='red',lwd=2)
raster::contour(BathyCroped,levels=c(-550,-1000,-1500,-2000),add=TRUE)
plot(MyStations[MyStations$Stratum=='550-1000',],pch=21,bg='yellow',add=TRUE)
plot(MyStations[MyStations$Stratum=='1000-1500',],pch=21,bg='orange',add=TRUE)
plot(MyStations[MyStations$Stratum=='1500-2000',],pch=21,bg='red',add=TRUE)
par(Mypar)

#Example 3: Automatic numbers of stations, with distance constraint

MyStations=create_Stations(Poly=MyPoly,
           Bathy=BathyCroped,Depths=c(-550,-1000,-1500,-2000),Nauto=30,dist=10)
Mypar=par(mai=c(0,0,0,2)) #Figure margins as c(bottom, left, top, right)
plot(BathyCroped,breaks=Depth_cuts, col=Depth_cols, legend=FALSE,axes=FALSE,box=FALSE)
add_Cscale(offset = 50,height = 90,fontsize = 0.8,width=25)
plot(MyPoly,add=TRUE,border='red',lwd=2)
raster::contour(BathyCroped,levels=c(-550,-1000,-1500,-2000),add=TRUE)
plot(MyStations[MyStations$Stratum=='550-1000',],pch=21,bg='yellow',add=TRUE)
plot(MyStations[MyStations$Stratum=='1000-1500',],pch=21,bg='orange',add=TRUE)
plot(MyStations[MyStations$Stratum=='1500-2000',],pch=21,bg='red',add=TRUE)
par(Mypar)




[Package CCAMLRGIS version 3.0.7 Index]