-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
SC0_sf <- function(x) {
coords <- wk::wk_coords(x)
udata <- unjoin::unjoin(coords[c("x", "y", "ring_id", "feature_id")], .data$x, .data$y)
vertex <- setNames(udata$.idx0[c("x", "y", ".idx0")], c("x_", "y_", "vertex_"))
udata$data$coord <- 1:nrow(udata$data)
segs <- udata$data %>% dplyr::select(.data$ring_id, .data$coord, .data$feature_id) %>%
dplyr::mutate(.cx0 = .data$coord, ## specify in segment terms
.cx1 = .data$coord + 1L) %>%
dplyr::group_by(.data$ring_id) %>% dplyr::slice(-dplyr::n()) %>% dplyr::ungroup() %>%
dplyr::transmute(.data$.cx0, .data$.cx1, path_ = .data$ring_id, object = .data$feature_id)
object <- sc_object(x)
segs[[".vx0"]] <- udata$data$.idx0[match(segs$.cx0, udata$data$coord)]
segs[[".vx1"]] <- udata$data$.idx0[match(segs$.cx1, udata$data$coord)]
## but udata$.idx0 has the vertices, with .idx0 as the mapping
object$topology_ <- split(segs[c(".vx0", ".vx1", "path_")], segs$object)
meta <- tibble::tibble(proj = crsmeta::crs_wkt(x), ctime = Sys.time())
vertex <- vertex %>%
dplyr::arrange(.data$vertex_)
bad <- !names(vertex) %in% c("x_", "y_", "z_", "m_", "t_")
if (any(bad)) vertex <- vertex[!bad]
structure(list(object = object, vertex = vertex,
meta = meta),
class = c("SC0", "sc"))
}above use 'parcels_hobart' i.e.
f <- raadfiles::thelist_files(pattern = "parcels_hobart")$fullname
x <- sf::read_sf(f)
SC0(x)
class : SC0
type : Structural
vertices : 195295 (2-space)
primitives : 463141 (2-space)
crs : GDA94 / MGA zone 55also see for a more exhaustive exploration: dcooley/geometries#4
Metadata
Metadata
Assignees
Labels
No labels
