我有一个,带有lat lon
( SHP_4283< -sf :: ST_TRANSFORM(SHP,CRS = 4283)
)
和3个变量,我想绘制单独的
$ bistrate
要分离颜色和 $ GEOMETRY
位置的因素。
使用geom_sf ..
ggplot() +
geom_sf(data = subset(shp_4283, Substrate == "Sand", show.legend = "point"), #aes(shape = YOU),
color = "yellow", size = 1) +
geom_sf(data = subset(shp_4283, Substrate == "Mixed reef and sand", show.legend = "point"), #aes(shape = YOU),
color = "green", size = 1) +
geom_sf(data = subset(shp_4283, Substrate == "None modelled with certainty", show.legend = "point"), #aes(shape = YOU),
color = "grey", size = 2) +
geom_sf(data = subset(shp_4283, Substrate == "Reef", show.legend = "point"), #aes(shape = YOU),
color = "black", size = 2, show.legend = T) +
coord_sf()
绘图有效,但没有传说为no aes()
set ..但是,由于“ x [j]中的错误:无效的下标类型'list'列表'”
i i了解要创建一个新的 df
过滤每个因素及其几何形状,然后从..
df <- shp_4283 %>%
# Your filter
filter(Substrate == "Reef") %>%
# 2 Extract coordinates
st_coordinates() %>%
# 3 to table /tibble
as.data.frame() %>%
**is this where i would code the 'column names' so that each
filtered $Substrate factor in a new df would be labelled appropriately?**
但是否有一个 geom _ ..
用使用SF DF绘制单独可变因子的方法它是几何..和传说将颜色映射到因子?
i have a shp file , with lat lon
( shp_4283 <- sf::st_transform(shp, crs = 4283)
)
and 3 variables, of which i would like to plot the separate
$Substrate
factors to separate colours and to their $geometry
locations.
with geom_sf..
ggplot() +
geom_sf(data = subset(shp_4283, Substrate == "Sand", show.legend = "point"), #aes(shape = YOU),
color = "yellow", size = 1) +
geom_sf(data = subset(shp_4283, Substrate == "Mixed reef and sand", show.legend = "point"), #aes(shape = YOU),
color = "green", size = 1) +
geom_sf(data = subset(shp_4283, Substrate == "None modelled with certainty", show.legend = "point"), #aes(shape = YOU),
color = "grey", size = 2) +
geom_sf(data = subset(shp_4283, Substrate == "Reef", show.legend = "point"), #aes(shape = YOU),
color = "black", size = 2, show.legend = T) +
coord_sf()
the plot works, but with no legend as no aes()
set.. but then further errors occur due to "Error in x[j] : invalid subscript type 'list'"
I understand to create a new df
filtering each factor and its geometry to then plot from..
df <- shp_4283 %>%
# Your filter
filter(Substrate == "Reef") %>%
# 2 Extract coordinates
st_coordinates() %>%
# 3 to table /tibble
as.data.frame() %>%
**is this where i would code the 'column names' so that each
filtered $Substrate factor in a new df would be labelled appropriately?**
but is there a geom_..
way to plot separate variable factor from the sf df with its geometry.. and the legend mapping the color to the factor?
发布评论
评论(1)
geom_sf()&amp; subset()&amp;显式层调用
逐渐较大的数据组之上
要查看最小的数据组最后,在此帖子的 ( geom_解释)
不同的变量因子(
$ bistrate
)是1。地理绘制,它们的2.各自的可见性很容易调节,取决于 layer ,它们是从初始编码的。 ggplot()
呼叫(最远/最后最突出)。然后,geom_sf()
点(不是geom_point()
),通过 color , shape )和<强>点的大小(alpha =
也可用)。geom_sf() & subset() & explicit layer call
to view the smallest data-group last, on top of the progressively larger data-groups beneath
also thanks to this post (geom_ explanation)
the different variable factors (
$Substrate
) are 1. geo-plotted, and their 2. respective visibility, is easily adjustable, dependent on the layer at which they are coded from initialggplot()
call (farthest/last most prominent). Thegeom_sf()
points (notgeom_point()
) are then made prominent through colour, shape, and size of point (alpha =
also available).