Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
options(tidyverse.quiet = TRUE)
library(tidyverse)
library(sf)
#> Linking to GEOS 3.8.1, GDAL 3.1.1, PROJ 6.3.1

gist_url <- "https://gist.githubusercontent.com/njtierney/0d61ff809f2c8b72ae70204dfce740cf/raw/ffef6895973203e6b8a125aac4d9d175508cea0c/example-route.R"

source(gist_url)

aawt_dat_1_5 %>% 
  mutate(centroid = st_centroid(geometry))
#> Warning: Problem with `mutate()` input `centroid`.
#> ℹ st_centroid does not give correct centroids for longitude/latitude data
#> ℹ Input `centroid` is `st_centroid(geometry)`.
#> Warning in st_centroid.sfc(geometry): st_centroid does not give correct
#> centroids for longitude/latitude data
#> Simple feature collection with 5 features and 1 field
#> Active geometry column: geometry
#> geometry type:  MULTILINESTRING
#> dimension:      XY
#> bbox:           xmin: 146.2154 ymin: -37.95333 xmax: 146.451 ymax: -37.53749
#> geographic CRS: WGS 84
#>                                    name                       geometry
#> 1         Day 01 Walhalla-O'Sheas Track MULTILINESTRING ((146.4486 ...
#> 2     Day 02 O'Sheas - St Gwinear Track MULTILINESTRING ((146.3843 ...
#> 3   Day 03 St Gwinear - Stronachs Track MULTILINESTRING ((146.3019 ...
#> 4   Day 04 Stronachs - Red Jacket Track MULTILINESTRING ((146.2161 ...
#> 5 Day 05 Red Jacket - Black River Track MULTILINESTRING ((146.2968 ...
#>                     centroid
#> 1 POINT (146.4228 -37.93844)
#> 2 POINT (146.3478 -37.88386)
#> 3 POINT (146.2527 -37.79371)
#> 4 POINT (146.2674 -37.70138)
#> 5 POINT (146.3674 -37.60473)

Created on 2020-11-16 by the reprex package (v0.3.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment