Dear list,

In my GRASS GIS database I have the vector map 'inmap', which is a 
vegetation map with different vegetation types defined in column 'VT'. I 
want to split the vector map according to the VT in different vector 
maps as part of a larger script. I wrote a small script following the 
steps described below:

First I extract the values of the column VT into a character vector 
namelist1

 > namelist1:
  [1] "Acacia and allied vegetation"
  [2] "Alpine"
  [3] "Bamboo woodland and thicket"
  [4] "Bare land"

Because I want to avoid spaces in the names of the resulting vector 
maps, I convert namelist1 into namelist2:

 > namelist2
  [1] "Acacia_and_allied_vegetation"
  [2] "Alpine"
  [3] "Bamboo_woodland_and_thicket"
  [4] "Bare_land"

I am using these two as input for v.extract, using a loop (for this 
occassion using doGRASS instead of execGRASS):

for(i in 1:length(namelist1){
    param <- list(input=inmap, output=namelist2[i], 
where=paste("Name","='",namelist1[i], "'",sep=""))
    flags <- c("d")
    doGRASS("v.extract", parameters=param, flags=flags)
}

For i=1, the following is send to GRASS:
v.extract -d input=trapnel1 output=Acacia_and_allied_vegetation 
where=\"Name='Acacia and allied vegetation'\""

For i=2, the following is send to GRASS:
v.extract -d input=trapnel1 output=Alpine where=Name='Alpine'

In the second example the argument for the second parameter 'where' is 
not surrounded by double quotation marks, resulting in an error in the 
execution of the command in GRASS. This always seems to happen when the 
argument consist of one string without spaces.

For now I am running the same command via system call - 
system(paste("v.extract -d input='",inmap, "' output='", namelist3[i], 
"' where=\" VT='", namelist1[i], "'\"", sep="")) -, which works fine. 
However, I would like to know what/if I am doing something wrong here.


Best regards

Paulo


	[[alternative HTML version deleted]]

