[R-sig-Geo] warnings and errors from grass to R via spgrass6GG
Rainer M. Krug
Rainer at krugs.de
Thu Apr 18 15:16:44 CEST 2013
Rainer at krugs.de (Rainer M. Krug) writes:
> Roger Bivand <Roger.Bivand at nhh.no> writes:
>
>> On Tue, 16 Apr 2013, Rainer M. Krug wrote:
>>
>>> Hi
>>>
>>> I am using spgrass6 with grass 7 and can report that it works so far
>>> without problems.
>>>
>>> Nevertheless, I have one question, which I already had about grass 6.
>>>
>>> I am using execGRASS to execute grass commands as well as an own defined
>>> function r.mapcalc [1].
>>>
>>> Now as these are used in a simulation script, I would like to (actually
>>> need to know) when these functions fail.
>>
>> Rainer:
>>
>> Could you please create a simple test case with some built-in data set
>> and initGRASS()? I see from ?system that some cases are addressed, but
>> with intern=TRUE.
>
> I'll investigate further and will send some examples using the spearhead
> dataset.
Hi Roger
one example is simply the following:
,----
| > execGRASS(
| "r.stats",
| input = "fire_blocksgg",
| flags = c("C", "n"),
| intern = TRUE)
| + + + + ERROR: Raster map <fire_blocksgg> not found
| character(0)
| attr(,"status")
| [1] 1
| Warning message:
| running command 'r.stats -C -n input=fire_blocksgg' had status 1
| >
`----
here the error on grass side becomes translated into a warning. Changing
intern=FALSE results in no warning.
Lat me know if you would like to have more examples.
Cheers,
Rainer
>
> Thanks,
>
> Rainer
>
>>
>> Roger
>>
>>>
>>> Is there a way that errors and warnings in GRASS will be reflected as
>>> errors and warnings in R when tthe grass function is called via execGRASS?
>>>
>>> I am using Linux and R 3.0.0
>>>
>>> Thanks,
>>>
>>> Rainer
>>>
>>>
>>> Footnotes:
>>> [1] r.mapcalc is defined as follow:
>>> --8<---------------cut here---------------start------------->8---
>>> r.mapcalc <- function(
>>> ...,
>>> intern = TRUE,
>>> ignore.stderr = !options("asmDebug")[[1]],
>>> feedback = TRUE,
>>> flags = NULL
>>> ) {
>>> comm <- paste( "r.mapcalc ", " \"", ..., "\" ", sep="" )
>>> if (!is.null(flags)) {
>>> flags <- paste0("--", flags, collapse=" ")
>>> }
>>> comm <- paste(comm, flags)
>>> if (feedback) print(comm)
>>> system( comm, intern=intern, ignore.stderr=ignore.stderr )
>>> }
>>> --8<---------------cut here---------------end--------------->8---
>>>
>>>
>>>
>>>
>>>
>>>
> <#secure method=pgpmime mode=sign>
>
<#secure method=pgpmime mode=sign>
--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)
Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa
Tel : +33 - (0)9 53 10 27 44
Cell: +33 - (0)6 85 62 59 98
Fax : +33 - (0)9 58 10 27 44
Fax (D): +49 - (0)3 21 21 25 22 44
email: Rainer at krugs.de
Skype: RMkrug
More information about the R-sig-Geo
mailing list