stat_spat_coordinates {tidyterra} | R Documentation |
Extract coordinates from SpatVector
objects
Description
stat_spat_coordinates()
extracts the coordinates from SpatVector
objects
and summarises them to one pair of coordinates (x and y) per geometry.
Usage
stat_spat_coordinates(
mapping = aes(),
data = NULL,
geom = "point",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
Arguments
mapping |
Set of aesthetic mappings created by aes() . If specified and
inherit.aes = TRUE (the default), it is combined with the default mapping
at the top level of the plot. You must supply mapping if there is no plot
mapping.
|
data |
A SpatVector object, see terra::vect() .
|
geom |
The geometric object to use to display the data for this layer.
When using a stat_*() function to construct a layer, the geom argument
can be used to override the default coupling between stats and geoms. The
geom argument accepts the following:
A Geom ggproto subclass, for example GeomPoint .
A string naming the geom. To give the geom as a string, strip the
function name of the geom_ prefix. For example, to use geom_point() ,
give the geom as "point" .
For more information and other ways to specify the geom, see the
layer geom documentation.
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The position argument accepts the following:
The result of calling a position function, such as position_jitter() .
This method allows for passing extra arguments to the position.
A string naming the position adjustment. To give the position as a
string, strip the function name of the position_ prefix. For example,
to use position_jitter() , give the position as "jitter" .
For more information and other ways to specify the position, see the
layer position documentation.
|
na.rm |
If FALSE , the default, missing values are removed with
a warning. If TRUE , missing values are silently removed.
|
show.legend |
logical. Should this layer be included in the legends?
NA , the default, includes if any aesthetics are mapped.
FALSE never includes, and TRUE always includes.
You can also set this to one of "polygon", "line", and "point" to
override the default legend.
|
inherit.aes |
If FALSE , overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. borders() .
|
... |
Other arguments passed on to ggplot2::stat_sf_coordinates() .
|
Details
Wrapper of ggplot2::stat_sf_coordinates()
.
See ggplot2::stat_sf_coordinates()
for details.
Value
A ggplot2 layer
See Also
Other ggplot2 utils:
autoplot.Spat
,
fortify.Spat
,
geom_spat_contour
,
geom_spatraster()
,
geom_spatraster_rgb()
,
ggspatvector
Examples
cyl <- terra::vect(system.file("extdata/cyl.gpkg", package = "tidyterra"))
library(ggplot2)
ggplot(cyl) +
stat_spat_coordinates()
ggplot(cyl) +
geom_errorbarh(
aes(
geometry = geometry,
xmin = after_stat(x) - 50000,
xmax = after_stat(x) + 50000,
y = after_stat(y),
height = 10000
),
stat = "sf_coordinates"
)
[Package
tidyterra version 0.6.1
Index]