<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<DEFANGED_META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<DEFANGED_META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7226.0">
<TITLE>SV: SV: [STATSGRASS] spgrass6 rastget6 bug??</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><TT><FONT SIZE=2>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<BR>
sink("new_version.R") etc.<BR>
<BR>
I'll change the function in the package when I have access to the codebase.<BR>
<BR>
Roger<BR>
<BR>
<BR>
---<BR>
Roger Bivand, NHH, Helleveien 30, N-5045 Bergen,<BR>
Roger.Bivand@nhh.no<BR>
<BR>
<BR>
<BR>
-----Opprinnelig melding-----<BR>
Fra: Ulrich Leopold [<A HREF="mailto:uleopold@science.uva.nl">mailto:uleopold@science.uva.nl</A>]<BR>
Sendt: to 23.03.2006 15:17<BR>
Til: Roger Bivand<BR>
Kopi: uleopold@science.uva.nl; statsgrass@grass.itc.it<BR>
Emne: Re: SV: [STATSGRASS] spgrass6 rastget6 bug??<BR>
<BR>
> Please try the command by hand within R with debug(rast.get6). When<BR>
> rast.get6() calls other interface functions, please enter debug(that_function)<BR>
> to follow the trail all the way back to the command that is giving the<BR>
> progress report. If the annoying progress percentages are on stderr, probably<BR>
> they can be caught somewhere, but first we need to see where they are coming<BR>
> from and stop them.<BR>
<BR>
Roger, I used<BR>
<BR>
debug(rast.get6(c("surface_alzette_sealed", "precip_obkp"), cat=c(TRUE,FALSE)))<BR>
<BR>
but it did not stop anywhere and produced a large entry in the RAM (1.5GB).<BR>
But I was watching the processes and it came to my mind that r.out.arc could<BR>
cause teh problem. So I checked on the GRASS commandline to be sure and it<BR>
indeed gives the progress percentage.<BR>
<BR>
So I used the following command to stop GRASS writing a message to stderr:<BR>
<BR>
r.out.arc input=map output=map.txt 2>/dev/null<BR>
<BR>
This command "r.out.arc" is used by readFLOAT6sp in rast.get6 on line 11 (here<BR>
line 12). But where can I built in now "2>/dev/null" there and write the new<BR>
function?<BR>
<BR>
readFLOAT6sp<BR>
function (vname)<BR>
{<BR>
pid <- as.integer(round(runif(1, 1, 1000)))<BR>
p4 <- CRS(getLocationProj())<BR>
for (i in seq(along = vname)) {<BR>
gtmpfl1 <- system(paste("g.tempfile pid=", pid, sep = ""),<BR>
intern = TRUE)<BR>
rtmpfl1 <- ifelse(.Platform$OS.type == "windows",<BR>
system(paste("cygpath -w",<BR>
gtmpfl1, sep = " "), intern = TRUE), gtmpfl1)<BR>
system(paste("r.out.arc input=", vname[i], " output=",<BR>
gtmpfl1, sep = ""))<BR>
res <- readAsciiGrid(rtmpfl1, colname = vname[i], proj4string = p4)<BR>
to_int <- length(which(unlist(strsplit(system(paste("r.info -t",<BR>
vname[i]), intern = TRUE), "=")) == "CELL")) > 0<BR>
if (to_int)<BR>
res@data[[1]] <- as.integer(res@data[[1]])<BR>
unlink(rtmpfl1)<BR>
if (i == 1)<BR>
resa <- res<BR>
else {<BR>
grida <- getGridTopology(resa)<BR>
grid <- getGridTopology(res)<BR>
if (!isTRUE(all.equal(grida, grid)))<BR>
stop("topology is not equal")<BR>
onames <- c(names(resa@data), names(res@data))<BR>
ncols <- dim(resa@data)[2]<BR>
lst <- vector(mode = "list", length = ncols + 1)<BR>
names(lst) <- onames<BR>
for (i in 1:ncols) lst[[i]] <- resa@data[[i]]<BR>
lst[[ncols + 1]] <- res@data[[1]]<BR>
resa <- SpatialGridDataFrame(grid = grida, data = AttributeList(lst),<BR>
proj4string = p4)<BR>
}<BR>
}<BR>
resa<BR>
}<BR>
<BR>
<BR>
<BR>
<BR>
<BR>
> ---<BR>
> Roger Bivand, NHH, Helleveien 30, N-5045 Bergen,<BR>
> Roger.Bivand@nhh.no<BR>
><BR>
><BR>
><BR>
> -----Opprinnelig melding-----<BR>
> Fra: statsgrass-admin@grass.itc.it på vegne av Ulrich Leopold<BR>
> Sendt: to 23.03.2006 10:58<BR>
> Til: statsgrass@grass.itc.it<BR>
> Emne: [STATSGRASS] spgrass6 rastget6 bug??<BR>
><BR>
> Dear list,<BR>
><BR>
> I am trying to automate some statistics with the help of the latest version of<BR>
> spgrass6 and rastget6. The problem I encounter is that when I load maps from<BR>
> within GRASS-6.0.1 with<BR>
><BR>
> alzette <- rast.get6(c("surface_alzette_sealed", "precip_obkp"), cat=c(TRUE,<BR>
> FALSE))<BR>
><BR>
> it shows a progress which only counts to 96%. Then this number blocks the next<BR>
> command in a script. The only way to get around it is to press return on the<BR>
> command line which I cannot do in the script.<BR>
><BR>
> Is this a bug. And if yes. Do you know any work arounds?<BR>
><BR>
> Any help appreciated.<BR>
><BR>
> Cheers, Ulrich<BR>
<BR>
<BR>
</FONT></TT>
</P>
</BODY>
</HTML>