I have a simple feature collection (lines) with the geometry type "MULTILINESTRING" that i want to plot with ggplot2. The line thickness should represent the value of a field. Unfortunately I am not able to provide a reprex. But maybe there is an obvious mistake that can be easily identified.
lines
Output:
Simple feature collection with 171 features and 1 field
geometry type: MULTILINESTRING
dimension: XY
bbox: xmin: 579649.7 ymin: 5801899 xmax: 625387 ymax: 5851019
projected CRS: ETRS89 / UTM zone 32N
First 10 features:
strahler geometry
1 1 MULTILINESTRING ((580016.3 ...
2 1 MULTILINESTRING ((582188.7 ...
3 1 MULTILINESTRING ((581499.9 ...
4 1 MULTILINESTRING ((586581.9 ...
5 1 MULTILINESTRING ((584296.4 ...
6 1 MULTILINESTRING ((583833.5 ...
7 1 MULTILINESTRING ((584608.8 ...
8 1 MULTILINESTRING ((583096.1 ...
9 1 MULTILINESTRING ((588869.2 ...
10 1 MULTILINESTRING ((587474.7 ...
I am plotting it with
lines %>%
mutate(strahler = as.integer(strahler)) %>%
ggplot() +
geom_sf(aes(size = strahler))
The result looks really messy. It seems that using size this way affects the vertices of the lines.
Reprex
When I tried to provide a reprex, this messy look didn't occur
lines <-
tibble(
x = c(1, 2, 5, 2, 4),
y = c(0, 3, 4, 3, 2),
order = c(2L, 2L, 2L, 1L, 1L)
) %>%
st_as_sf(coords = c("x", "y")) %>%
st_sf(crs = 25832) %>%
group_by(order) %>%
summarise() %>%
st_cast("MULTILINESTRING")
lines
Simple feature collection with 2 features and 1 field
geometry type: MULTILINESTRING
dimension: XY
bbox: xmin: 1 ymin: 0 xmax: 5 ymax: 4
projected CRS: ETRS89 / UTM zone 32N
# A tibble: 2 x 2
strahler geometry
<int> <MULTILINESTRING [m]>
1 1 ((2 3, 4 2))
2 2 ((1 0, 2 3, 5 4))
Plotting it
lines %>%
mutate(strahler = as.integer(strahler)) %>%
ggplot() +
geom_sf(aes(size = strahler))
I guess it has to do with the geometry field which looks different but I don't know how to convert it. I am happy about any hint!