[R-sig-Geo] gdal color tables
Roger Bivand
Roger.Bivand at nhh.no
Sun Dec 23 21:23:46 CET 2012
On Sun, 23 Dec 2012, Agustin Lobo wrote:
> Roger,
>
> The problem is not getting a color table as colmat in your
> example, but writing colmat in gdal format to create pseudocolor raster
> files, best using either writeRaster() or writeGDAL() (a bit like you
> would display a raster layer
> in R using plot() and the col argument).
> The way I was thinking on was writing
> the greylevel raster with the current writeRaster() and then writing
> an R function to create a
> vrt file that, from one single layer, is essentially the color palette
> in gdal format
> (see http://trac.osgeo.org/gdal/wiki/FAQRaster#Howtocreateormodifyanimagecolortable).
> Then the vrt file can be translated to any other format using gdal_translate.
> But then I thought that a more direct function could already exist in
> R, thus I asked.
There is no support in raster or sp objects for symbology, and unless
someone extends the classes to accommodate symbology on a dynamic
by-attribute basis, it isn't going to happen.
Possibly writeGDAL could set a colortable on the output Byte raster, in
the way that I did show. First you would need to generate an RGB
raster/grid object, then quantize it, and output the result. That was the
point of the code I showed. If you need the facility, you can write it at
the R level using the lower-level GDAL interface code from an RGB object.
I guess that is something you could contribute using a vector of R
colours, col2rbg, and the breaks between colours to partition a numeric
raster (use findIntervals). Maybe you can re-use code in classInt?
Roger
>
> The mention to rgb2pct.py was just to show the format of the palette.
>
> On Sun, Dec 23, 2012 at 3:54 PM, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>> .../...
>>
>> Wrapping this in cat() and paste() to get the desired XML should not be
>> hard.
>
> ...which definitely means that the function does not exist. I'll try,
> either as you say
> or perhaps using R package xml. At least I'll write a function to make
> QGIS color tables,
> I think the format is the same as in gdal.
>
> Agus
>
>
>> Hope this clarifies,
>>
>> Roger
>>
>>
>>>
>>> An alternative could be using
>>>
>>> http://en.geopublishing.org/gdal%20colorpalette%20to%20symbology%20encoding
>>>
>>> but have not tried myself (yet).
>>>
>>> I understand, that, as far as you know, such a function does not exist.
>>>
>>> Agus
>>>
>>>> Barry
>>>>
>>>> _______________________________________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at r-project.org
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>
>> --
>> Roger Bivand
>> Department of Economics, NHH Norwegian School of Economics,
>> Helleveien 30, N-5045 Bergen, Norway.
>> voice: +47 55 95 93 55; fax +47 55 95 95 43
>> e-mail: Roger.Bivand at nhh.no
>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list