Type: | Package |
Title: | Processing Linear Features |
Version: | 1.0.1 |
Date: | 2021-09-13 |
Maintainer: | Shannon E Albeke <salbeke@uwyo.edu> |
Description: | Assists in the manipulation and processing of linear features with the help of the 'sf' package. Makes use of linear referencing to extract data from most shape files. Reference for this packages methods: Albeke, S.E. et al. (2010) <doi:10.1007/s10980-010-9528-4>. |
BugReports: | https://gitlab.com/albekeecoinfolab/rlft/-/issues |
Depends: | R (≥ 3.3.0), Rcpp (≥ 1.0.2), sf (≥ 0.9-1) |
Encoding: | UTF-8 |
License: | GPL (≥ 3) |
LazyData: | true |
LinkingTo: | Rcpp |
RoxygenNote: | 7.1.2 |
Suggests: | testthat, knitr, rmarkdown, ggplot2 |
VignetteBuilder: | knitr |
NeedsCompilation: | yes |
Packaged: | 2021-09-23 22:08:01 UTC; wkirkpa2 |
Author: | Samuel Fay [aut], William Kirkpatrick [aut], Shannon E Albeke [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2021-09-24 04:10:02 UTC |
rLFT: Processing Linear Features
Description
Assists in the manipulation and processing of linear features with the help of the 'sf' package. Makes use of linear referencing to extract data from most shape files. Reference for this packages methods: Albeke, S.E. et al. (2010) <doi:10.1007/s10980-010-9528-4>.
Details
Currently the only function available is for calculating the convexity of boundaries in a given shp file.
rLFT functions
The function bct
takes in an sf object and returns raw convexity,
convexity index, and sinuosity at certain point intervals along a given linear feature.
Author(s)
Maintainer: Shannon E Albeke salbeke@uwyo.edu
Authors:
Samuel Fay smafay6@gmail.com
William Kirkpatrick wkirkpa2@uwyo.edu
See Also
Useful links:
Report bugs at https://gitlab.com/albekeecoinfolab/rlft/-/issues
Calculate Boundary Convexity
Description
Cpp function that calculates convexity of a single feature.
Usage
CalcBoundaryConvex(
feature,
windowSize,
stepSize,
fid,
rid,
filename = "",
noRID = TRUE
)
Arguments
feature |
A NumericMatrix that holds the data of one feature from the given sf object. |
windowSize |
A double describing the diameter of the window used to measure convexity. |
stepSize |
A double describing the distance between measurements along an arc. |
fid |
An integer that holds the current feature id. |
rid |
A string that holds the unique route ID for the current feature. |
filename |
A string denoting the name of the file you wish to output convexity data to. |
noRID |
A boolean that denotes whether the given sf object has an RID column. |
Details
Cpp function that takes in a single feature from the given sf object and calculates raw convexity, convexity index, and sinuosity of that feature. It formats convexity data into a NumericMatrix and outputs it.
Value
matrix
Add M values to given feature
Description
Add measure values to a given linear feature and store them in the m-coordinate of the matrix. Returns the new matrix with added m-values. For more information on m-values and linear referencing see: http://desktop.arcgis.com/en/arcmap/10.3/guide-books/linear-referencing/what-is-linear-referencing.htm
Usage
addM(feature)
Arguments
feature |
A NumericMatrix that holds the data of a single linear feature taken from a given sf object. |
Value
matrix
Add M values to given feature
Description
Add M values to a given linear feature and store them in the m-coordinate of the sf object. Returns the new sf object with added m-values. For more information on m-values and linear referencing see: http://desktop.arcgis.com/en/arcmap/10.3/guide-books/linear-referencing/what-is-linear-referencing.htm
Usage
addMValues(sfDataObject)
Arguments
sfDataObject |
An sf object. Must be a LINESTRING, POLYGON, MULTIPOLYGON, or MULTILINESTRING |
Value
Returns the new sfDataObject
with added m-values. The class of the output is sf
.
Examples
library(rLFT)
data("shpObject")
# Assign M Values to each vertex
mValues <- addMValues(shpObject)
print("M Values Added")
head(st_coordinates(mValues))
Boundary Convexity Tool
Description
Calculates raw convexity, convexity index, and sinuosity of a given sf object and returns a data frame with all measurements for each step and feature. If provided, the data will also be output to a tab delimited file.
Usage
bct(sfDataObject, step, window, ridName = NULL, filename = "")
Arguments
sfDataObject |
An sf Object containing shape file data. |
step |
A numeric describing the distance between measurements along an arc. |
window |
A numeric describing the diameter of the window used to measure convexity. |
ridName |
A character denoting the column name where the unique ID for each feature is stored in given sf object. |
filename |
A character denoting the name of the file you wish to output convexity data to in tab delimited format. Must have the .txt extension. |
Details
This function will reject any sf object with a geographic coordinate system, so consider projecting your features. Your sf object must be of either type LINESTRING, MULTILINESTRING, POLYGON, or MULTIPOLYGON. If a given POLYGON or MUTLIPOLYGON contains inner rings, they will be ignored. If a unique ID Column name is not provided, the function will generate a unique ID for each feature. The arguments step
and window
can be any non-negative numeric. The argument ridName
MUST be a character indicating the name of the column in your sf object where the route id is stored.
Value
The output of this function is a data.frame
that contains all measurements for each step and feature.
Reference
Albeke, S.E. et al. “Measuring boundary convexity at multiple spatial scales using a linear “moving window” analysis: an application to coastal river otter habitat selection.” Landscape Ecology 25 (2010): 1575-1587. [linked phrase](https://link.springer.com/article/10.1007/s10980-010-9528-4)
Examples
library(rLFT)
data("shpObject")
#store convexity output data in a variable 'outputTable'
outputTable <- bct(shpObject, step = 50, window = 100, ridName = "RID")
formatTable
Description
Formats a data frame with all the convexity data of a feature and that features corresponding ID's. If no Route ID value is given, one will be generated, otherwise the given Route ID will be used and a feature ID will be generated.
Usage
formatTable(cppMatrix, rid, fid, noRID)
Arguments
cppMatrix |
A matrix holding the convexity data of a given feature |
rid |
A character that represents the unique Route ID of a feature |
fid |
A numeric that represents the current feature |
noRID |
A literal that denotes whether or not a Route ID value was given |
Value
outDF A data frame holding all the convexity data of a feature and its corresponding ID's
An example sf object outlining boundaries of a group of islands in Alaska in the lat/lon CRS.
Description
A dataset with coordinates (x, y, z) of 3 linear features with a geometry type of MULTIPOLYGON and a geographic coordinate system (longlat)
Usage
latlongShpObject
Format
A data frame with 1 row and 10 variables
Open a file for output
Description
Opens a file for writing and writes all of the convexity data taken from the given sf object to the given file.
Usage
openOutput(filename, noRID)
Arguments
filename |
A string denoting the name of the file you wish to output convexity data to. |
noRID |
A boolean that denotes whether the given sf object has an RID column. |
An example sf object with geometry type of POINT, used for testing.
Description
An example sf object with geometry type of POINT, used for testing.
Usage
pointObject
Format
An object of class sf
(inherits from data.frame
) with 1 rows and 2 columns.
An example sf object outlining boundaries of a group of islands in Alaska cast as POLYGON.
Description
A dataset with coordinates (x, y) of 37 features with a geometry type of POLYGON and a projected coordinate system (aea). These features represent the same data as 'shpObject' but this sf object has been cast to be of geometry type POLYGON. There are also inner polygons on some features.
Usage
polygonShpObject
Format
A data frame with 37 rows and 2 variables
- Id
Id's of all features
- geometry
coordinates of feature (x,y)
Route ID Check
Description
Checks the given Route ID and makes sure it exists and if it does assigns FALSE to the variable noRID. Otherwise it will stop the program if the given Route ID does not exist or just assign noRID to TRUE if no RID was given.
Usage
ridCheck(sfDataObject, ridName)
Arguments
sfDataObject |
An sf Object containing shape file data. |
ridName |
A character denoting the column name where the unique Route ID for each feature is stored in given sf object. |
Value
noRID A literal denoting whether or not an RID value was given
An example sf object outlining boundaries of a group of islands in Alaska cast as LINESTRING.
Description
A dataset with coordinates (x, y) of 37 linear features with a geometry type of LINESTRING and a projected coordinate system (aea). These particular features represent several small islands in Alaska.
Usage
shpObject
Format
A data frame with 37 rows and 2 variables
- RID
Route ID of the features
- geometry
coordinates of feature (x, y)
Creates a list of features that have been skipped over
Description
Takes in a vector and pushes the feature ID into the vector
Usage
skipFeatureList(x, i)
Arguments
x |
A NumericVector to hold all the skipped features |
i |
ID of the skipped feature |