[R-sig-Geo] unexpected attribute plotting with sf polygons
Waichler, Scott R
Scott@W@|ch|er @end|ng |rom pnn|@gov
Fri Sep 27 16:37:39 CEST 2024
Hi, When I plot the "sf" and "data.frame" object my.poly2 below, all of the polygons are the same color, despite my setting two different values for the Attribute. What have I done wrong?
my.text <-
c("POLYGON ((0 2.69, 4.483057 2.86, 4.483057 2.76, 0 2.59, 0 2.69))",
"POLYGON ((0 2.59, 4.483057 2.76, 4.483057 2.26, 0 2.09, 0 2.59))",
"POLYGON ((0 2.09, 4.483057 2.26, 4.483057 1.26, 0 1.09, 0 2.09))",
"POLYGON ((0 1.09, 4.483057 1.26, 4.483057 -0.74, 0 -0.91, 0 1.09))")
my.poly <- st_as_sfc(my.text)
mat <- matrix(c(rep(1, 4), rep(2, 4)), byrow=F, ncol=2)
my.poly2 <- st_sf(Attribute = mat, geom = my.poly)
plot(my.poly2, breaks = c(0.5, 1.5, 2.5))
Thank you,
Scott Waichler, PhD
Pacific Northwest National Lab
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list