The layers that draw an rpic_sf() data frame as pic drew it, to add to a
ggplot() — alone or over a basemap. Shapes go through
ggplot2::geom_sf() with their fill and stroke columns (pic colours
are hex strings already, so the scales are identity scales); every text
(geopic_kind "text" and "title") is a label at its point through
ggplot2::geom_sf_text(), justified and turned as pic placed it — the
geopic_anchor compass becomes hjust/vjust (above puts the point at
the label's bottom, ljust at its left) and geopic_rotation becomes
angle; a label written bold, italic or mono keeps its face
(geopic_font_weight, geopic_font_style, geopic_font_family become
fontface and the "mono" family). ggplot2::coord_sf() with clip = "off" completes the list, so
labels at the drawing's edge are not cut.
Arguments
- x
a georeferenced drawing: an
rpic_sf()data frame, or anythingrpic_sf()takes — apic()object or pic source (then...are its georeferencing arguments:anchor,scale,bearing,frame,features, ...).- ...
passed to
rpic_sf()whenxis pic source; an error otherwise.- linewidth
line width of the shapes, in
ggplot2units (mm).NULLdraws each shape at pic's own width (thestroke_widthcolumn, points, 0.8 by default).- text_size
size of the labels, in
ggplot2units (mm).
Details
The result is a list of layers and scales: add it to a plot with +.
Layers added before it (a basemap) are drawn under the drawing, layers
added after it on top; axes and theme are the plot's own —
vignette("maps") shows the longitude/latitude grid with
theme_minimal(), autoplot.rpic_source() hides it with theme_void().
See also
autoplot.rpic_source() for the one-call map; rpic_sf() for
the data and its columns; add_rpic() for an interactive MapLibre map.
Examples
if (requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("sf", quietly = TRUE)) {
radius <- pic('geo_lon = -34.8711; geo_lat = -8.0631; geo_scale = 1000
C: circle rad 2 at (0, 0) dashed fill 0.97
line from C.c to C.e thin
"2 km" above at 0.5 <C.c, C.e>') |>
rpic_sf()
ggplot2::ggplot() + rpic_layers(radius) + ggplot2::theme_minimal()
}
#> Warning: 'x' is NULL so the result will be NULL