-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
speed prospects with {wk} #140
Comments
here's some sf helpers, segments and triangles (to avoid closing vertex dupe) as linestrings sf_segment <- function(x) {
sc <- silicate::SC0(x)
topol <- silicate::sc_object(sc)$topology_
idx <- t(as.matrix(do.call(rbind, topol)[c(".vx0", ".vx1")]))
d <- silicate::sc_vertex(sc)[as.vector(idx), c("x_", "y_")]
d$feature_id <- rep(seq_len(dim(idx)[2L]), each = 2L)
out <- sfheaders::sf_linestring(d, x = "x_", y = "y_", linestring_id = "feature_id")
out$feature_id <- rep(seq_along(topol), unlist(lapply(topol, nrow)))
out
}
sf_triangle <- function(x, verts = c("x_", "y_")) {
if (inherits(x, "TRI0")) {
## might alread be sc DEL0 or TRI0
sc <- x
} else {
sc <- silicate::TRI0(x)
}
topol <- silicate::sc_object(sc)$topology_
idx <- t(as.matrix(do.call(rbind, topol)[c(".vx0", ".vx1", ".vx2")]))
d <- silicate::sc_vertex(sc)[as.vector(idx), verts]
d$feature_id <- rep(seq_len(dim(idx)[2L]), each = 3L)
out <- sfheaders::sf_linestring(d, x = verts[1], y = verts[2L], linestring_id = "feature_id")
out$feature_id <- rep(seq_along(topol), unlist(lapply(topol, nrow)))
out
}
example(read_sf)
plot(sf_segment(nc))
plot(sf_triangle(minimal_mesh))
plot(sf_triangle(anglr::DEL0(nc, max_area = .02))) |
what are the key pathways? for example, turning sf polygons or lines into segments does not require vertex deduplication, so rather than go through SC0 every time we really only need the map of paths (number of coordinates in each), to use as a grouping I think fleshing that list out, in light of traipse, rayshader, mapdeck, and various discussions around the place is worthwhile - like, when do you want segments? sometimes you want them all and to know what polygon they belong to, other times you need an actual mesh of segments for planar partition ... this is where sf fails us, we don't want to copy out every vertex instance ... |
above use 'parcels_hobart' i.e.
also see for a more exhaustive exploration: dcooley/geometries#4
The text was updated successfully, but these errors were encountered: