Attribute Creation
linestring_sf2$name = c("Riddle Rd", "Marshall Ave", "Foulke St")
linestring_sf2$length = st_length(linestring_sf2)
linestring_sf2
## Simple feature collection with 3 features and 2 fields
## Geometry type: LINESTRING
## Dimension: XY
## Bounding box: xmin: 1 ymin: 1 xmax: 4 ymax: 5
## CRS: NA
## geom name length
## 1 LINESTRING (1 5, 4 3) Riddle Rd 3.605551
## 2 LINESTRING (4 4, 4 1) Marshall Ave 3.000000
## 3 LINESTRING (2 2, 4 2) Foulke St 2.000000
linestring_sf2 |>
ggplot() +
geom_sf(aes(color = name)) +
geom_sf_label(aes(label = name)) +
labs(title = "Linestring") +
theme_minimal() +
theme(legend.position = "none") +
xlim(0,5)
![](bookclub-geocompr_files/figure-html/unnamed-chunk-84-1.png)