Skip to content
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

smoothr - apply to ARC #64

Open
mdsumner opened this issue Mar 15, 2018 · 5 comments
Open

smoothr - apply to ARC #64

mdsumner opened this issue Mar 15, 2018 · 5 comments

Comments

@mdsumner
Copy link
Member

https://github.com/mstrimas/smoothr

Apply this to arcs and recompose for topological-aware smoothing

@mdsumner
Copy link
Member Author

mdsumner commented Mar 15, 2018

First stab

library(silicate)
library(sf)
data(wrld_simpl, package = "maptools")
w <- st_as_sf(wrld_simpl)
#x <- polymesh
x <- subset(w, NAME %in% c("Brazil", "Paraguay", "Bolivia", "Peru", "Colombia")) #rmapshaper::ms_simplify(inlandwaters[c(3, 6), ])
a <- ARC(x)



b <- a$arc_link_vertex %>% split(.$arc_) %>% 
  purrr::map(~smoothr::smooth_chaikin(dplyr::inner_join(.x, a$vertex) %>% 
                                       dplyr::select(x_, y_) %>% as.matrix(), refinements = 3, wrap = FALSE))
# b <- a$arc_link_vertex %>% split(.$arc_) %>% 
#   purrr::map(~smoothr::smooth_spline(dplyr::inner_join(.x, a$vertex) %>% 
#                                        dplyr::select(x_, y_) %>% as.matrix(), n = nrow(.x) * 4, wrap = FALSE))


op <- par(mfrow = c(2, 1), mar = rep(0, 4))
plot(x$geometry, col = NA, border = NA, asp = "")
purrr::walk(b, lines, col = "red")
plot(x$geometry, asp = "")
par(op)

image

image

@mpadge
Copy link
Member

mpadge commented Mar 15, 2018

That is so cool!

@mdsumner
Copy link
Member Author

mdsumner commented Mar 15, 2018

Isn't it? It's what I thought would be easy in #45 and #60, and there's so many applications.

@mdsumner
Copy link
Member Author

Try to implement Visvalingam https://bost.ocks.org/mike/simplify/ and https://gist.github.com/msbarry/9152218

@mdsumner
Copy link
Member Author

Vis is done here: hypertidy/area#3

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

No branches or pull requests

2 participants