create_CircularArrow: Create Circular Arrow

View source: R/create_CircularArrow.R

create_CircularArrowR Documentation

Create Circular Arrow

Description

Create one or multiple arrows on an elliptical path, or a custom path (using Input). This function uses create_Arrow and create_Ellipse. Defaults are set for a simplified Weddell Sea gyre.

Usage

create_CircularArrow(
  Latc = -67,
  Lonc = -30,
  Lmaj = 800,
  Lmin = 500,
  Ang = 140,
  Npe = 100,
  dir = "cw",
  Narr = 1,
  Spc = 0,
  Stp = 0,
  Npa = 50,
  Pwidth = 5,
  Hlength = 15,
  Hwidth = 10,
  dlength = 0,
  Atype = "normal",
  Acol = "green",
  Atrans = 0,
  yx = FALSE,
  Input = NULL
)

Arguments

Latc

numeric, latitude of the ellipse centre in decimal degrees, or Y projected coordinate if yx is set to TRUE.

Lonc

numeric, longitude of the ellipse centre in decimal degrees, or X projected coordinate if yx is set to TRUE.

Lmaj

numeric, length of major axis.

Lmin

numeric, length of minor axis.

Ang

numeric, angle of rotation (0-360).

Npe

integer, number of points on the ellipse.

dir

character, direction along the ellipse, either "cw" (clockwise) or "ccw" (counterclockwise).

Narr

integer, number of arrows.

Spc

integer, spacing between arrows, or length of single arrow.

Stp

numeric, starting point of an arrow on the ellipse (0 to 1).

Npa

integer, number of points to build the path of the arrow.

Pwidth

numeric, width of the arrow's path.

Hlength

numeric, length of the arrow's head.

Hwidth

numeric, width of the arrow's head.

dlength

numeric, length of dashes for dashed arrows.

Atype

character, arrow type either "normal" or "dashed". A normal arrow is a single polygon, with a single color (set by Acol) and transparency (set by Atrans). A dashed arrow is a series of polygons which can be colored separately by setting two or more values as Acol=c("color start","color end") and two or more transparency values as Atrans=c("transparency start","transparency end"). The length of dashes is controlled by dlength.

Acol

Color of the arrow, see Atype above.

Atrans

Numeric, transparency of the arrow, see Atype above.

yx

Logical, if set to TRUE the input coordinates are projected. Give Y in the first column, X in the second.

Input

Either NULL, or a projected spatial object to control the arrow's path (see examples).

Value

Spatial object in your environment.

See Also

create_Ellipse, create_Arrow, create_Polys, add_Legend.

Examples


# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#27-create-circular-arrow

#Example 1
Arr=create_CircularArrow()

terra::plot(SmallBathy(),xlim=c(-3e6,0),ylim=c(0,3e6),breaks=Depth_cuts,
            col=Depth_cols,axes=FALSE,box=FALSE,legend=FALSE,main="Example 1")
plot(st_geometry(Coast[Coast$ID=='All',]),col='grey',add=TRUE)
plot(st_geometry(Arr),col=Arr$col,border=NA,add=TRUE)


#Example 2
Arr=create_CircularArrow(Narr=2,Spc=5)

terra::plot(SmallBathy(),xlim=c(-3e6,0),ylim=c(0,3e6),breaks=Depth_cuts,
            col=Depth_cols,axes=FALSE,box=FALSE,legend=FALSE,main="Example 2")
plot(st_geometry(Coast[Coast$ID=='All',]),col='grey',add=TRUE)
plot(st_geometry(Arr),col=Arr$col,border=NA,add=TRUE)


#Example 3
Arr=create_CircularArrow(Narr=10,Spc=-4,Hwidth=15,Hlength=20)

terra::plot(SmallBathy(),xlim=c(-3e6,0),ylim=c(0,3e6),breaks=Depth_cuts,
            col=Depth_cols,axes=FALSE,box=FALSE,legend=FALSE,main="Example 3")
plot(st_geometry(Coast[Coast$ID=='All',]),col='grey',add=TRUE)
plot(st_geometry(Arr),col=Arr$col,border=NA,add=TRUE)


#Example 4
Arr=create_CircularArrow(Narr=8,Spc=-2,Npa=200,Acol=c("red","orange","green"),
                         Atrans = c(0,0.9,0),Atype = "dashed")

terra::plot(SmallBathy(),xlim=c(-3e6,0),ylim=c(0,3e6),breaks=Depth_cuts,
            col=Depth_cols,axes=FALSE,box=FALSE,legend=FALSE,main="Example 4")
plot(st_geometry(Coast[Coast$ID=='All',]),col='grey',add=TRUE)
plot(st_geometry(Arr),col=Arr$col,border=NA,add=TRUE)


#Example 5 Path around two ellipses
El1=create_Ellipse(Latc=-61,Lonc=-50,Lmaj=500,Lmin=250,Ang=120)
El2=create_Ellipse(Latc=-68,Lonc=-57,Lmaj=400,Lmin=200,Ang=35)
#Merge ellipses and take convex hull
El=st_union(st_geometry(El1),st_geometry(El2))
El=st_convex_hull(El)
El=st_segmentize(El,dfMaxLength = 10000)
#Go counterclockwise if desired:
#El=st_coordinates(El)
#El=st_polygon(list(El[nrow(El):1,])) 

Arr=create_CircularArrow(Narr=10,Spc=3,Npa=200,Acol=c("green","darkgreen"),
                         Atype = "dashed",Input=El)

terra::plot(SmallBathy(),xlim=c(-3e6,0),ylim=c(0,3e6),breaks=Depth_cuts,
            col=Depth_cols,axes=FALSE,box=FALSE,legend=FALSE,main="Example 5")
plot(st_geometry(Coast[Coast$ID=='All',]),col='grey',add=TRUE)
plot(st_geometry(Arr),col=Arr$col,border=NA,add=TRUE)





CCAMLRGIS documentation built on Oct. 15, 2024, 9:10 a.m.