# NOT RUN {
#First, create a polygon within which stations will be created
MyPolys=create_Polys(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(MyPoly,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(MyPoly,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(MyPoly,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)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab