Duccio Aiazzi

SPTools is a package to create, edit and convert spatial objects of the package "sp".


Install SPTools from its GitHub repository. You first need to install the sp and devtools packages.

install.packages(c("sp", "devtools"))

Then install SPTools using the install_github function in the devtools package.


Example use

splitLines splits each single line contained in a SpatialLines object into segments of a specific length.

c1 = cbind(c(0,2,5,7), c(0,2,3,3))
l1 = Line(c1)
sl = list(Lines(list(l1), ID = 1))
SP = SpatialLines(sl)
SPs = splitLines(SP, 0.4, plot.results = T)

linedf2SpatialLines converts a dataframe with IDs and coordinates into a SpatialLines object. SpatialLines2df performes the reverse operation, extracting the coordinates and IDs of each lines of a SpatialLines object and put into a dataframe. createBox and createCircle create a rectangle and a polygon approximating a circle in the form of a SpatialPolygons object.


The SPTools package as a whole is distributed under [GPL-3 (GNU General Public License version 3)[].

duccioa/sptools documentation built on May 3, 2019, 1:48 p.m.