gparse: Example function for tileset processing.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Full example of using R to create state gSSURGO files via GRASS tilesets.

Usage

1
gparse(tilesize = 2000, rc, outname, blocksize = 2)

Arguments

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.

Details

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).

Value

This function returns nothing in R.

Author(s)

Sarah Goslee <sarah.goslee@ars.usda.gov>

See Also

createTiles, processTiles, mergeTiles, removeTiles

Examples

 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)

phiala/grassR documentation built on May 25, 2019, 2:55 a.m.