Learn R Programming

aqp (version 2.1.0)

as: Coerce SoilProfileCollection with as()

Description

SoilProfileCollections can be coerced to other R object types using as(spc, 'type').

Possible endpoints include: list, data.frame, SpatialPointsDataFrame and SpatialPoints.

Usage

# S4 method for SoilProfileCollection
as.data.frame(x)

Value

list

data.frame

tbl_df

data.table

SpatialPointsDataFrame

sf

SpatialPoints

Arguments

x

a SoilProfileCollection

Examples

Run this code
# load example data stored as SoilProfileCollection
data(sp5)

# sp5
str(sp5)

# list output
str(as(sp5, 'list'))

# data.frame output
str(as(sp5, 'data.frame'))

# Spatial Objects
# make some random coordinate data for each profile
sp5$x <- sp5$y <- rnorm(length(sp5))
initSpatial(sp5, crs = "OGC:CRS84") <- ~ x + y

if (requireNamespace("sf")) {

  # sf output
  str(as(sp5, 'sf'))

  # SpatialPointsDataFrame output
  str(as(sp5, 'SpatialPointsDataFrame'))

  # SpatialPoints output
  str(as(sp5, 'SpatialPoints'))
  
}

Run the code above in your browser using DataLab