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

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

Value

list

data.frame

tbl_df

data.table

SpatialPointsDataFrame

SpatialPoints

Examples

# load example data stored as SoilProfileCollection
data(sp5)

# sp5
str(sp5)
#> Formal class 'SoilProfileCollection' [package "aqp"] with 9 slots
#>   ..@ idcol       : chr "soil"
#>   ..@ hzidcol     : chr "hzID"
#>   ..@ depthcols   : chr [1:2] "top" "bottom"
#>   ..@ metadata    :List of 10
#>   .. ..$ aqp_df_class    : chr "data.frame"
#>   .. ..$ aqp_group_by    : chr ""
#>   .. ..$ aqp_hzdesgn     : chr ""
#>   .. ..$ aqp_hztexcl     : chr ""
#>   .. ..$ depth_units     : chr "cm"
#>   .. ..$ stringsAsFactors: logi FALSE
#>   .. ..$ original.order  : int [1:1539] 1 2 3 4 5 6 7 8 9 10 ...
#>   .. ..$ target.order    : int [1:1539] 1 2 3 4 5 6 7 8 9 10 ...
#>   .. ..$ citation        : chr "F. Carre, M.C. Girard. 2002. Quantitative mapping of soil types based on regression kriging of taxonomic distan"| __truncated__
#>   .. ..$ dateAdded       : Date[1:1], format: "2018-12-27"
#>   ..@ horizons    :'data.frame':	1539 obs. of  18 variables:
#>   .. ..$ soil      : chr [1:1539] "soil1" "soil1" "soil1" "soil1" ...
#>   .. ..$ sand      : num [1:1539] 32.3 29 34.9 38.2 32.2 25.2 24.4 24 21.2 18.4 ...
#>   .. ..$ silt      : num [1:1539] 10.9 11.2 11.6 10.9 10.8 ...
#>   .. ..$ clay      : num [1:1539] 52.8 58.2 51.9 49.7 55.6 ...
#>   .. ..$ R25       : num [1:1539] 0.41 0.31 0.31 0.31 0.55 0.43 0.44 0.34 0.35 0.35 ...
#>   .. ..$ G25       : num [1:1539] 0.38 0.28 0.28 0.28 0.46 0.37 0.37 0.28 0.27 0.27 ...
#>   .. ..$ B25       : num [1:1539] 0.34 0.25 0.25 0.25 0.36 0.3 0.31 0.23 0.19 0.19 ...
#>   .. ..$ pH        : num [1:1539] 6.85 8.08 9.2 9.29 9.24 8.26 8.95 9.34 9.24 9.13 ...
#>   .. ..$ EC        : num [1:1539] 24 10 23.9 41.6 73.6 14.5 16.1 26.1 43.8 61.5 ...
#>   .. ..$ CaCO3     : num [1:1539] 0.05 0.05 0.3 0.4 0.7 0.1 0.5 1 1.05 1.1 ...
#>   .. ..$ C         : num [1:1539] 2.29 0.9 0.74 0.35 0.25 1.06 0.66 0.58 0.47 0.36 ...
#>   .. ..$ Ca        : num [1:1539] 183 234 231 168 203 ...
#>   .. ..$ Mg        : num [1:1539] 146 172 166 152 167 ...
#>   .. ..$ Na        : num [1:1539] 19 34.1 70.2 81.7 100 ...
#>   .. ..$ top       : int [1:1539] 0 8 25 55 100 0 10 25 40 70 ...
#>   .. ..$ bottom    : int [1:1539] 8 25 55 100 267 10 25 40 70 100 ...
#>   .. ..$ soil_color: chr [1:1539] "#696157" "#4F4740" "#4F4740" "#4F4740" ...
#>   .. ..$ hzID      : chr [1:1539] "1" "2" "3" "4" ...
#>   ..@ site        :'data.frame':	296 obs. of  1 variable:
#>   .. ..$ soil: chr [1:296] "soil1" "soil10" "soil100" "soil101" ...
#>   ..@ sp          :Formal class 'SpatialPoints' [package "sp"] with 3 slots
#>   .. .. ..@ coords     : num [1, 1] 0
#>   .. .. ..@ bbox       : logi [1, 1] NA
#>   .. .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
#>   .. .. .. .. ..@ projargs: chr NA
#>   ..@ diagnostic  :'data.frame':	0 obs. of  0 variables
#>   ..@ restrictions:'data.frame':	0 obs. of  0 variables

# list output
str(as(sp5, 'list'))
#> List of 9
#>  $ idcol       : chr "soil"
#>  $ hzidcol     : chr "hzID"
#>  $ depthcols   : chr [1:2] "top" "bottom"
#>  $ metadata    :List of 10
#>   ..$ aqp_df_class    : chr "data.frame"
#>   ..$ aqp_group_by    : chr ""
#>   ..$ aqp_hzdesgn     : chr ""
#>   ..$ aqp_hztexcl     : chr ""
#>   ..$ depth_units     : chr "cm"
#>   ..$ stringsAsFactors: logi FALSE
#>   ..$ original.order  : int [1:1539] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..$ target.order    : int [1:1539] 1 2 3 4 5 6 7 8 9 10 ...
#>   ..$ citation        : chr "F. Carre, M.C. Girard. 2002. Quantitative mapping of soil types based on regression kriging of taxonomic distan"| __truncated__
#>   ..$ dateAdded       : Date[1:1], format: "2018-12-27"
#>  $ horizons    :'data.frame':	1539 obs. of  18 variables:
#>   ..$ soil      : chr [1:1539] "soil1" "soil1" "soil1" "soil1" ...
#>   ..$ sand      : num [1:1539] 32.3 29 34.9 38.2 32.2 25.2 24.4 24 21.2 18.4 ...
#>   ..$ silt      : num [1:1539] 10.9 11.2 11.6 10.9 10.8 ...
#>   ..$ clay      : num [1:1539] 52.8 58.2 51.9 49.7 55.6 ...
#>   ..$ R25       : num [1:1539] 0.41 0.31 0.31 0.31 0.55 0.43 0.44 0.34 0.35 0.35 ...
#>   ..$ G25       : num [1:1539] 0.38 0.28 0.28 0.28 0.46 0.37 0.37 0.28 0.27 0.27 ...
#>   ..$ B25       : num [1:1539] 0.34 0.25 0.25 0.25 0.36 0.3 0.31 0.23 0.19 0.19 ...
#>   ..$ pH        : num [1:1539] 6.85 8.08 9.2 9.29 9.24 8.26 8.95 9.34 9.24 9.13 ...
#>   ..$ EC        : num [1:1539] 24 10 23.9 41.6 73.6 14.5 16.1 26.1 43.8 61.5 ...
#>   ..$ CaCO3     : num [1:1539] 0.05 0.05 0.3 0.4 0.7 0.1 0.5 1 1.05 1.1 ...
#>   ..$ C         : num [1:1539] 2.29 0.9 0.74 0.35 0.25 1.06 0.66 0.58 0.47 0.36 ...
#>   ..$ Ca        : num [1:1539] 183 234 231 168 203 ...
#>   ..$ Mg        : num [1:1539] 146 172 166 152 167 ...
#>   ..$ Na        : num [1:1539] 19 34.1 70.2 81.7 100 ...
#>   ..$ top       : int [1:1539] 0 8 25 55 100 0 10 25 40 70 ...
#>   ..$ bottom    : int [1:1539] 8 25 55 100 267 10 25 40 70 100 ...
#>   ..$ soil_color: chr [1:1539] "#696157" "#4F4740" "#4F4740" "#4F4740" ...
#>   ..$ hzID      : chr [1:1539] "1" "2" "3" "4" ...
#>  $ site        :'data.frame':	296 obs. of  1 variable:
#>   ..$ soil: chr [1:296] "soil1" "soil10" "soil100" "soil101" ...
#>  $ sp          :Formal class 'SpatialPoints' [package "sp"] with 3 slots
#>   .. ..@ coords     : num [1, 1] 0
#>   .. ..@ bbox       : logi [1, 1] NA
#>   .. ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
#>   .. .. .. ..@ projargs: chr NA
#>  $ diagnostic  :'data.frame':	0 obs. of  0 variables
#>  $ restrictions:'data.frame':	0 obs. of  0 variables

# data.frame output
str(as(sp5, 'data.frame'))
#> 'data.frame':	1539 obs. of  18 variables:
#>  $ soil      : chr  "soil1" "soil1" "soil1" "soil1" ...
#>  $ sand      : num  32.3 29 34.9 38.2 32.2 25.2 24.4 24 21.2 18.4 ...
#>  $ silt      : num  10.9 11.2 11.6 10.9 10.8 ...
#>  $ clay      : num  52.8 58.2 51.9 49.7 55.6 ...
#>  $ R25       : num  0.41 0.31 0.31 0.31 0.55 0.43 0.44 0.34 0.35 0.35 ...
#>  $ G25       : num  0.38 0.28 0.28 0.28 0.46 0.37 0.37 0.28 0.27 0.27 ...
#>  $ B25       : num  0.34 0.25 0.25 0.25 0.36 0.3 0.31 0.23 0.19 0.19 ...
#>  $ pH        : num  6.85 8.08 9.2 9.29 9.24 8.26 8.95 9.34 9.24 9.13 ...
#>  $ EC        : num  24 10 23.9 41.6 73.6 14.5 16.1 26.1 43.8 61.5 ...
#>  $ CaCO3     : num  0.05 0.05 0.3 0.4 0.7 0.1 0.5 1 1.05 1.1 ...
#>  $ C         : num  2.29 0.9 0.74 0.35 0.25 1.06 0.66 0.58 0.47 0.36 ...
#>  $ Ca        : num  183 234 231 168 203 ...
#>  $ Mg        : num  146 172 166 152 167 ...
#>  $ Na        : num  19 34.1 70.2 81.7 100 ...
#>  $ top       : int  0 8 25 55 100 0 10 25 40 70 ...
#>  $ bottom    : int  8 25 55 100 267 10 25 40 70 100 ...
#>  $ soil_color: chr  "#696157" "#4F4740" "#4F4740" "#4F4740" ...
#>  $ hzID      : chr  "1" "2" "3" "4" ...

# Spatial Objects
# make some random coordinate data for each profile
sp5$x <- sp5$y <- rnorm(length(sp5))
coordinates(sp5) <- ~ x + y

# SpatialPointsDataFrame output
str(as(sp5, 'SpatialPointsDataFrame'))
#> only site data are extracted
#> Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
#>   ..@ data       :'data.frame':	296 obs. of  1 variable:
#>   .. ..$ soil: chr [1:296] "soil1" "soil10" "soil100" "soil101" ...
#>   ..@ coords.nrs : num(0) 
#>   ..@ coords     : num [1:296, 1:2] -1.2248 0.0849 0.5814 0.4506 0.497 ...
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:296] "1" "2" "3" "4" ...
#>   .. .. ..$ : chr [1:2] "x" "y"
#>   ..@ bbox       : num [1:2, 1:2] -3.1 -3.1 2.69 2.69
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:2] "x" "y"
#>   .. .. ..$ : chr [1:2] "min" "max"
#>   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
#>   .. .. ..@ projargs: chr NA

# SpatialPoints output
str(as(sp5, 'SpatialPoints'))
#> Formal class 'SpatialPoints' [package "sp"] with 3 slots
#>   ..@ coords     : num [1:296, 1:2] -1.2248 0.0849 0.5814 0.4506 0.497 ...
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:296] "1" "2" "3" "4" ...
#>   .. .. ..$ : chr [1:2] "x" "y"
#>   ..@ bbox       : num [1:2, 1:2] -3.1 -3.1 2.69 2.69
#>   .. ..- attr(*, "dimnames")=List of 2
#>   .. .. ..$ : chr [1:2] "x" "y"
#>   .. .. ..$ : chr [1:2] "min" "max"
#>   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
#>   .. .. ..@ projargs: chr NA