Description Usage Arguments Details Value Author(s) See Also Examples
Full example of using R to create state gSSURGO files via GRASS tilesets.
1 | gparse(tilesize = 2000, rc, outname, blocksize = 2)
|
tilesize |
Size of tiles to use. The default is usually best. |
rc |
A dataframe containing gSSURGO values. |
outname |
The name to use for the final output file. |
blocksize |
Block size for merging. The default is usually best. |
This function uses the *Tiles() functions in the grassR package to process gSSURGO files in an efficient fashion. The 10m gSSURGO files are too large to import into R for an entire state, so they must be processed in chunks (tiles).
This function returns nothing in R.
Sarah Goslee <sarah.goslee@ars.usda.gov>
createTiles
, processTiles
, mergeTiles
, removeTiles
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Not run:
# start GRASS
# start R within grass
# load rc data file
rcall <- read.table("/data/gis/notes/gssurgo/gssurgo-valu.csv")
gparse(rc=rcall, outname="gssurgo")
## The function is currently defined as
function (tilesize = 2000, rc, outname, blocksize = 2)
{
gssurgoFUN <- function(x, basename, rc) {
thisdata <- x@data
colnames(thisdata)[1] <- "cell"
thisdata <- data.frame(index = seq_len(nrow(thisdata)),
thisdata)
thisdata <- merge(thisdata, rc, all.x = TRUE)
thisdata <- thisdata[order(thisdata$index), ]
outnames <- vector(mode = "character", length = 0)
for (j in seq_len(ncol(rc))) {
thisname <- colnames(rc)[j]
x@data[, 1] <- thisdata[, thisname]
thistempfile <- paste(basename, thisname, sep = ".")
writeRAST6(x, thistempfile)
outnames <- c(outnames, thistempfile)
}
outnames
}
tileindex <- createTiles("gssurgo", tilesize = tilesize)
tileindex <- processTiles(tileindex, baserast = "gssurgo",
FUN = gssurgoFUN, rc = rc)
mergeTiles(tileindex, blocksize = blocksize, outname = outname)
removeTiles(tileindex)
invisible()
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.