create_Arrow {CCAMLRGIS} | R Documentation |
Create Arrow
Description
Create an arrow which can be curved and/or segmented.
Usage
create_Arrow(
Input,
Np = 50,
Pwidth = 5,
Hlength = 15,
Hwidth = 10,
dlength = 0,
Atype = "normal",
Acol = "green",
Atrans = 0,
yx = FALSE
)
Arguments
Input |
input dataframe with at least two columns (Latitudes then Longitudes) and an
optional third column for weights. First row is the location of the start of the arrow,
Last row is the location of the end of the arrow (where the arrow will point to). Optional
intermediate rows are the locations of points towards which the arrow's path will bend.
Weights (third column) can be added to the intermediate points to make the arrow's path
bend more towards them. Projected coordinates may be used (Y then X) instead of Latitudes
and Longitudes by setting |
Np |
integer, number of additional points generated to create a curved path. If the
arrow's path appears too segmented, increase |
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 |
Value
Spatial object in your environment with colors included in the dataframe (see examples).
See Also
create_Points
, create_Lines
, create_Polys
,
create_PolyGrids
, create_Stations
, create_Pies
,
add_Legend
.
Examples
# For more examples, see:
# https://github.com/ccamlr/CCAMLRGIS#24-create-arrow
#Example 1: straight green arrow
myInput=data.frame(lat=c(-61,-52),
lon=c(-60,-40))
Arrow=create_Arrow(Input=myInput)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 1")
#Example 2: blue arrow with one bend
myInput=data.frame(lat=c(-61,-65,-52),
lon=c(-60,-45,-40))
Arrow=create_Arrow(Input=myInput,Acol="lightblue")
plot(st_geometry(Arrow),col=Arrow$col,main="Example 2")
#Example 3: blue arrow with two bends
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40))
Arrow=create_Arrow(Input=myInput,Acol="lightblue")
plot(st_geometry(Arrow),col=Arrow$col,main="Example 3")
#Example 4: blue arrow with two bends, with more weight on the second bend
#and a big head
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40),
w=c(1,1,2,1))
Arrow=create_Arrow(Input=myInput,Acol="lightblue",Hlength=20,Hwidth=20)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 4")
#Example 5: Dashed arrow, small dashes
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40),
w=c(1,1,2,1))
Arrow=create_Arrow(Input=myInput,Acol="blue",Atype = "dashed",dlength = 1)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 5",border=NA)
#Example 6: Dashed arrow, big dashes
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40),
w=c(1,1,2,1))
Arrow=create_Arrow(Input=myInput,Acol="blue",Atype = "dashed",dlength = 2)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 6",border=NA)
#Example 7: Dashed arrow, no dashes, 3 colors and transparency gradient
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40),
w=c(1,1,2,1))
Arrow=create_Arrow(Input=myInput,Acol=c("red","green","blue"),
Atrans = c(0,0.9,0),Atype = "dashed",dlength = 0)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 7",border=NA)
#Example 8: Same as example 7 but with more points, so smoother
myInput=data.frame(lat=c(-61,-60,-65,-52),
lon=c(-60,-50,-45,-40),
w=c(1,1,2,1))
Arrow=create_Arrow(Input=myInput,Np=200,Acol=c("red","green","blue"),
Atrans = c(0,0.9,0),Atype = "dashed",dlength = 0)
plot(st_geometry(Arrow),col=Arrow$col,main="Example 8",border=NA)