as.data.frame {GSIF}R Documentation

Converts an object of class "SoilProfileCollection" to a data frame

Description

Converts an object of class "SoilProfileCollection" to an object of class "data.frame" with both site and horizon data sorted in one row. Each original column name in the horizons table receives a sufix *_A, B, ..., Z where alphabetic letters represent horizon sequence.

Usage

## S4 method for signature 'SoilProfileCollection'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

object of class "SoilProfileCollection"

row.names

character; giving the row names for the data frame (missing values are not allowed)

optional

logical; if ‘TRUE’, setting row names and converting column names (to syntactic names: see ‘make.names’) is optional

...

optional arguments

Details

The advantage of converting the "SoilProfileCollection" data to a single table is that, once both tables have been merged to a single data frame, it can be more easily exported and visualized in a GIS and/or imported into a data base.

Note

Few profiles with a large number of horizons can make the whole data frame become large. Consider removing such locations or aggregating measured values per horizon to a lower number of horizons.

Author(s)

Tomislav Hengl and Brendan Malone

See Also

as.geosamples, mpspline

Examples

library(aqp)
library(plyr)
library(rgdal)
library(sp)
## sample profile from Nigeria:
lon = 3.90; lat = 7.50; id = "ISRIC:NG0017"; FAO1988 = "LXp" 
top = c(0, 18, 36, 65, 87, 127) 
bottom = c(18, 36, 65, 87, 127, 181)
ORCDRC = c(18.4, 4.4, 3.6, 3.6, 3.2, 1.2)
## prepare a SoilProfileCollection:
prof1 <- join(data.frame(id, top, bottom, ORCDRC), 
    data.frame(id, lon, lat, FAO1988), 
    type='inner')
depths(prof1) <- id ~ top + bottom
site(prof1) <- ~ lon + lat + FAO1988 
coordinates(prof1) <- ~ lon + lat
proj4string(prof1) <- CRS("+proj=longlat +datum=WGS84")
## convert to a simple table:
x <- as.data.frame(prof1)
str(x)
## horizons only
horizons <- getHorizons(x, idcol="id", sel=c("top", "bottom", "ORCDRC"))
horizons

[Package GSIF version 0.5-5 Index]