Created
January 7, 2016 16:58
-
-
Save Robinlovelace/ad5f28d7b32cf08a0d49 to your computer and use it in GitHub Desktop.
Demonstrates the use of mapshaper called from R to simplify spatial objects: https://github.com/ropensci/stplanr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # # # # # # # # # # # # # # # # # # # | |
# Simplify sp objects w. mapshaper # | |
# Needs https://nodejs.org installed # | |
# Tested on Windows and Linux # | |
# # # # # # # # # # # # # # # # # # # # | |
# # # # # # | |
# R setup # | |
# # # # # # | |
if(!require(devtools)) install.packages("devtools") # installs devtools if needs be | |
devtools::install_github("ropensci/stplanr") # install dev. version of stplanr | |
library(stplanr) # load the stplanr library | |
mapshape_available() # is mapshaper available to system()? | |
# # # # # # # # # # # | |
# data to simplify # | |
# # # # # # # # # # # | |
rnet <- overline(routes_fast) | |
rnet <- overline(routes_fast, attrib = "All") | |
# # # # # # # | |
# simplify # | |
# # # # # # # | |
rnet5 <- mapshape(rnet, percent = 5) | |
rnet1 <- mapshape(rnet, percent = 1) | |
rnets <- mapshape(rnet, ms_options = "snap-interval=0.001") | |
# # # # # | |
# plot # | |
# # # # # | |
par(mfrow = c(2,2)) | |
plot(rnet, main = "No simplification") | |
plot(rnet5, main = "5% simplification") | |
plot(rnet1, main = "1% simplification") | |
plot(rnets, main = "snap interval simplification") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
have you seen https://github.com/ateucher/rmapshaper?