[R-sig-Geo] [Fwd: v.reclass]
Agustin Lobo
alobolistas at gmail.com
Tue Sep 15 18:03:16 CEST 2009
-------- Original Message --------
Subject: v.reclass
Date: Tue, 15 Sep 2009 14:40:28 +0200
From: Agustin Lobo <alobolistas at gmail.com>
To: grass-stats at lists.osgeo.org
Hi again,
As a result of an R process, I have to reclassify
the input vector layer. Normally, I would do it
in R, but as the vector is huge, I prefer making the
rules file in R and use v.reclass in grass.
My goal is to reclassify field VALUE of vector Montseny07 according
to a table generated in R:
> b3rec[1:3,]
v
[1,] "18" "274"
[2,] "22" "274"
[3,] "117" "274
so that VALUE 18 would become 274 and so on.
I've made the following in R to create the rules file:
z <- file("delme.txt", "w")
for (i in 1:nrow(b3rec)){
writeLines(text=paste("VALUE",b3rec[i,2]), con = z, sep = "\n")
writeLines(text=paste("WHERE VALUE=",b3rec[i,1],sep=""), con=z, sep
= "\n")
}
close(z)
which creates a file delme.txt such as:
VALUE 274
WHERE VALUE=18
VALUE 274
WHERE VALUE=22
VALUE 274
WHERE VALUE=117
VALUE 274
WHERE VALUE=146
...
My understanding of this rules file was that
where we had VALUE 18, we would have VALUE 274
Nevertheless, when I run v.reclass, I get an error:
> system("v.reclass Montseny07 rules=delme.txt out=Monstseny07b3rec")
ERROR: Unknown rule option: 'VALUE'
So I remade the rules files using
cat 274
WHERE VALUE=18
etc
but then I get a vector object with a table with only one field cat. I
would prefer
having the same table as in the original vector, just with some of the
values
in field VALUE modified according to the rules file. Is there a way of
doing that?
Also, is there the equivalent to "* = *" in r.reclass to get the rest
of values unchanged?
Thanks!
Agus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alobolistas.vcf
Type: text/x-vcard
Size: 251 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090915/b9801479/attachment.vcf>
More information about the R-sig-Geo
mailing list