SV: SV: [STATSGRASS] spgrass6 rastget6 bug??

Roger Bivand Roger.Bivand at nhh.no
Thu Mar 23 11:17:02 EST 2006


If you can download the source package and edit that line in the only file in the R directory, then do R CMD INSTALL spgrass6, you'll get a version with your change which will stay around between R sessions. An even faster way is to say fix(readFLOAT6sp), you can edit it for that session (and maybe save it with 
sink("new_version.R") etc.

I'll change the function in the package when I have access to the codebase.

Roger


---
Roger Bivand, NHH, Helleveien 30, N-5045 Bergen,
Roger.Bivand at nhh.no



-----Opprinnelig melding-----
Fra: Ulrich Leopold [mailto:uleopold at science.uva.nl]
Sendt: to 23.03.2006 15:17
Til: Roger Bivand
Kopi: uleopold at science.uva.nl; statsgrass at grass.itc.it
Emne: Re: SV: [STATSGRASS] spgrass6 rastget6 bug??
 
> 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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-stats/attachments/20060323/b4ff1944/attachment.html


More information about the grass-stats mailing list