View source: R/create_CircularArrow.R
create_CircularArrow | R Documentation |
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.
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
)
Latc |
numeric, latitude of the ellipse centre in decimal degrees, or Y projected
coordinate if |
Lonc |
numeric, longitude of the ellipse centre in decimal degrees, or X projected
coordinate if |
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 |
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 |
Color of the arrow, see |
Atrans |
Numeric, transparency of the arrow, see |
yx |
Logical, if set to |
Input |
Either |
Spatial object in your environment.
create_Ellipse
, create_Arrow
, create_Polys
,
add_Legend
.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.