jmt2080ad / polylinesplitter Goto Github PK
View Code? Open in Web Editor NEWA tool that will split polylines and polygon perimeters.
A tool that will split polylines and polygon perimeters.
Really useful code! However, when I try splitting up a polyline into very small segments, I get an error. For example:
rivsplit <- splitLines(riv, dist = 1000) # this is OK
rivsplit <- splitLines(riv, dist = 10) # this results in an error
riv is a SpatialLine object with one feature. It is about 33 km long.
The error occurs at line 125 of polylineSplitter, at split(xydf,dist)
"Error in data.frame(x = x, y = y, end = end) : arguments imply differing number of rows: 7055, 7056"
Hi, nice set of functions. However, data on the sp object input is deleted. I'd like to keep the original data within the output, ie. duplicating rows.
I tried this, where Name is the original ID, however, it throws the folllowing Error object 'Name' not found:
splitLines2<- function(spobj, dist, start = T, sf = F){ xydf<-coordBuild(spobj) if (start == F){ xydf<-xydf[rev(rownames(xydf)),] } spoints <- split(xydf, dist) linelist <- list() lineslist <- list() id <- 1 Name <- Name if(!sf) { j <- 1 for(i in 1:(nrow(spoints)-1)){ linelist[j] <- Line(spoints[c(i, i + 1), c(1:2)]) j = j + 1 if(spoints[i+1,3] == 1){ lineslist[id]<-Lines(linelist, ID = id) id = id+1 Name = Name linelist<-list() j = 1 } } return(SpatialLinesDataFrame(SpatialLines(lineslist), data = data.frame(id = 0:(length(lineslist)-1), Name = Name))) } else { start <- 1 for(i in 1:(nrow(spoints)-1)){ if(spoints[i+1,3] == 1){ lineslist[[id]] <- sf::st_linestring(as.matrix(spoints[c(start:(i + 1)), c(1:2)], ncol = 2)) id <- id + 1 Name <- Name start <- i + 1 } } return(sf::st_sf(id = 1:length(lineslist), Name = Name, geom = sf::st_sfc(lineslist))) } }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.