```r
dg2<-rmapshaper::ms_simplify(grass_frags, keep = 0.02,keep_shapes = TRUE)
dist_mat<-st_distance(dg2)
#grass_frags %>% filter(area> 50000) ->dd
cts <- st_centroid(dg2)
```

```
## Warning in st_centroid.sf(dg2): st_centroid assumes attributes are constant
## over geometries of x
```