[R-sig-Geo] Landcover grd/gri Diva files in R

Agustin Lobo alobolistas at gmail.com
Sun May 20 22:39:19 CEST 2012


I confused the grd and the gri files, thanks for pointing it out.
But the question remains the same. Is there a function to read the
table with the legend from the grd file or should I make my own?
The best would be that, in case a couple of grd and gri files is
present, raster()
automatically created the table. Currently, I do not think raster()
reads anything from
the grd file, but I might be wrong.

Agus

2012/5/20 Barry Rowlingson <b.rowlingson at lancaster.ac.uk>:

>  Looking at the size of  the files, the .gri file contains the values
> and the .grd contains the meta-data. The raster() function doesn't
> care if you specify the .gri or the .grd, somehow it works out the
> file format and gets the info from both of them. However, as you say,
> its not reading in the labels...
>
>  The .grd file is a text file in Windows .ini file format, and the
> labels you want are in the [Legend] section:
>
> [Legend]
> Count=22
> Color1=16384
> Min1=1
> Max1=1
> Label1=Tree Cover, broadleaved, evergreen
> Color2=32768
> Min2=2
> Max2=2
> Label2=Tree Cover, broadleaved, deciduous, closed
> Color3=32768
> Min3=3
> Max3=3
>
>  etc...
>
> Shouldn't be too hard to read that in with readLines, look for the
> [Legend] section, and then get out the labels.
>
> Someone had a quick hack at reading ini files here:
>
> https://stat.ethz.ch/pipermail/r-help/2007-June/134055.html
>
> but it fails on your example because of some spaces somewhere.
>
> Don't readLines the .gri file! :)
>
> Barryy
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list