Learn R Programming

stplanr (version 0.1.4)

gprojected: Perform GIS functions on a temporary, projected version of a spatial object

Description

Perform GIS functions on a temporary, projected version of a spatial object

Usage

gprojected(shp, fun, crs = crs_select_aeq(shp), ...)

Arguments

shp
A spatial object with a geographic (WGS84) coordinate system
fun
A function to perform on the projected object (e.g. gLength))
crs
An optional coordinate reference system (if not provided it is set automatically by crs_select_aeq).
...
Arguments to pass to fun, e.g. byid = TRUE if the function is gLength))

Examples

Run this code
# Find the length of routes that are in lat/long format
rlength = gprojected(routes_fast, fun = rgeos::gLength, byid = TRUE)
plot(routes_fast$length, rlength)
cor(routes_fast$length, rlength)
rbuf = gprojected(routes_fast, rgeos::gBuffer, byid = TRUE, width = 100)
plot(rbuf)
raster::crs(rbuf)
plot(routes_fast, col = "green", add = TRUE)

Run the code above in your browser using DataLab