gToSp: Transform geometry to spatial object

Description Usage Arguments Value Examples

View source: R/geom_tools.r

Description

An object of class Spatial* is the sp-package representation of a geom.

Usage

1
gToSp(geom, crs = NULL)

Arguments

geom

[geom]
Object of class geom.

crs

[character(1)]
corrdinate reference system of the object in proj4 notation.

Value

Depending on the provided geometry either a SpatialPointsDataFrame, SpatialLinesDataFrame or SpatialPolygonsDataFrame object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
require(magrittr)
somePoints <- data.frame(X = c(5027609, 5190599, 5326537, 5222810,
                         5234735, 5281527, 5189955, 5041066),
                         Y = c(3977612, 3971119, 4028167, 3997230,
                         4060164, 4117856, 4118207, 4062838),
                         fid = c(1:8))

pointsGeom <- geomPoint(anchor = somePoints)
polyGeom <- gGroup(geom = pointsGeom, index = c(rep(1, 8))) %>%
  geomPolygon()

(spPoints <- gToSp(geom = pointsGeom, crs = projs$laea))
(spPolygon <- gToSp(geom = polyGeom, crs = projs$laea))

EhrmannS/rasterTools documentation built on Feb. 4, 2019, 11:22 a.m.