SV: [STATSGRASS] spgrass6 rastget6 bug??

Ulrich Leopold uleopold at science.uva.nl
Thu Mar 23 09:17:45 EST 2006


> Please try the command by hand within R with debug(rast.get6). When
> rast.get6() calls other interface functions, please enter debug(that_function)
> to follow the trail all the way back to the command that is giving the
> progress report. If the annoying progress percentages are on stderr, probably
> they can be caught somewhere, but first we need to see where they are coming
> from and stop them.

Roger, I used

debug(rast.get6(c("surface_alzette_sealed", "precip_obkp"), cat=c(TRUE,FALSE)))

but it did not stop anywhere and produced a large entry in the RAM (1.5GB).
But I was watching the processes and it came to my mind that r.out.arc could
cause teh problem. So I checked on the GRASS commandline to be sure and it
indeed gives the progress percentage.

So I used the following command to stop GRASS writing a message to stderr:

r.out.arc input=map output=map.txt 2>/dev/null

This command "r.out.arc" is used by readFLOAT6sp in rast.get6 on line 11 (here
line 12). But where can I built in now "2>/dev/null" there and write the new
function?

readFLOAT6sp
function (vname)
{
    pid <- as.integer(round(runif(1, 1, 1000)))
    p4 <- CRS(getLocationProj())
    for (i in seq(along = vname)) {
        gtmpfl1 <- system(paste("g.tempfile pid=", pid, sep = ""),
            intern = TRUE)
        rtmpfl1 <- ifelse(.Platform$OS.type == "windows",
system(paste("cygpath -w",
            gtmpfl1, sep = " "), intern = TRUE), gtmpfl1)
        system(paste("r.out.arc input=", vname[i], " output=",
            gtmpfl1, sep = ""))
        res <- readAsciiGrid(rtmpfl1, colname = vname[i], proj4string = p4)
        to_int <- length(which(unlist(strsplit(system(paste("r.info -t",
            vname[i]), intern = TRUE), "=")) == "CELL")) > 0
        if (to_int)
            res at data[[1]] <- as.integer(res at data[[1]])
        unlink(rtmpfl1)
        if (i == 1)
            resa <- res
        else {
            grida <- getGridTopology(resa)
            grid <- getGridTopology(res)
            if (!isTRUE(all.equal(grida, grid)))
                stop("topology is not equal")
            onames <- c(names(resa at data), names(res at data))
            ncols <- dim(resa at data)[2]
            lst <- vector(mode = "list", length = ncols + 1)
            names(lst) <- onames
            for (i in 1:ncols) lst[[i]] <- resa at data[[i]]
            lst[[ncols + 1]] <- res at data[[1]]
            resa <- SpatialGridDataFrame(grid = grida, data = AttributeList(lst),
                proj4string = p4)
        }
    }
    resa
}





> ---
> Roger Bivand, NHH, Helleveien 30, N-5045 Bergen,
> Roger.Bivand at nhh.no
>
>
>
> -----Opprinnelig melding-----
> Fra: statsgrass-admin at grass.itc.it på vegne av Ulrich Leopold
> Sendt: to 23.03.2006 10:58
> Til: statsgrass at grass.itc.it
> Emne: [STATSGRASS] spgrass6 rastget6 bug??
>
> Dear list,
>
> I am trying to automate some statistics with the help of the latest version of
> spgrass6 and rastget6. The problem I encounter is that when I load maps from
> within GRASS-6.0.1 with
>
> alzette <- rast.get6(c("surface_alzette_sealed", "precip_obkp"), cat=c(TRUE,
> FALSE))
>
> it shows a progress which only counts to 96%. Then this number blocks the next
> command in a script. The only way to get around it is to press return on the
> command line which I cannot do in the script.
>
> Is this a bug. And if yes. Do you know any work arounds?
>
> Any help appreciated.
>
> Cheers, Ulrich





More information about the grass-stats mailing list