Code Monkey home page Code Monkey logo

sfarc.node's Introduction

sfarc.node

R build status

The goal of sfarc.node is to extract unique shared boundaries (arcs) from sf polygons as sf lines.

Installation

You can install the dev version of sfarc.node from Github with:

remotes::install_github("mdsumner/sfarc.node")

Example

This shows examples of getting these shared boundaries. The feature id/s (the row number/s) from which each boundary came are listed in a list column, so that we can look up the original polygon/s for each arc. (There should be 1, or possibly 2 but results may vary wildly with unclean data).

library(sfarc.node)

f <- system.file("gpkg/nc.gpkg", package = "sf", mustWork = TRUE)
sfx <- sf::read_sf(f)
arcs <- sf_arcnode(sfx)
plot(arcs["arc"], col = sample(hcl.colors(nrow(arcs))))

We can get the original polygon id/s for a given boundary.

s <- sample(seq_len(dim(arcs)[1L]), 1L)
plot(sfx[arcs$feature_ids[[s]]$row, "geom"], reset = FALSE, col = c("grey", "grey10"))
plot(arcs[s, 1], add = TRUE, col = "hotpink2", lwd = 6)

plot(sfx$geom, col = sample(grey.colors(10), 100, replace = TRUE), reset = FALSE)
plot(dplyr::sample_n(arcs[1], 20), col = "hotpink2", lwd = 6, add = TRUE)

Works fine with more intensive data.

xx <- ozmaps::abs_ced
arx <- sf_arcnode(xx)

idx <- which(unlist(lapply(arx$feature_ids, function(.x) length(.x$row) > 1)))
s <- idx[1]
plot(xx[arx$feature_ids[[s]]$row, "geometry"], reset = FALSE, col = c("grey", "grey10"))
plot(arx[s, 1], add = TRUE, col = "hotpink2", lwd = 4)

for (j in 1:6) {
par(mfrow = c(5, 5), mar = rep(0, 4))
for (i in 1:25) {
s <- sample(idx, 1)
plot(xx[arx$feature_ids[[s]]$row, "geometry"], reset = FALSE, col = grey(c(0.8, 0.5)))
plot(arx[s, 1], add = TRUE, col = "hotpink1", lwd = 4)
}
}


Code of Conduct

Please note that the sfarc.node project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

sfarc.node's People

Contributors

mdsumner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

sfarc.node's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.