<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 22, 2014 at 8:11 AM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Fri, Feb 21, 2014 at 5:45 PM, Markus Metz<br>
<<a href="mailto:markus.metz.giswork@gmail.com">markus.metz.giswork@gmail.com</a>> wrote:<br>
> On Fri, Feb 21, 2014 at 5:39 PM, Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>> wrote:<br>
>> Unfortunately, I have data where GDAL does not identify the columns.<br>
><br>
> Does GDAL find a raster attribute table?<br>
><br>
>> One is<br>
>> the only string there, and the other three are the red, green, blue (in the<br>
>> range 0-1).<br>
><br>
> ... which would need to be transformed to the range 0,255.<br>
><br>
> Here it seems easier to edit the attribute table outside GRASS, then<br>
> use r.category and r.colors.<br>
><br>
>> For me it is clear what column I would like to transform to<br>
>> label and to color rules but I'm not sure if GDAL has even a chance to<br>
>> determine it somehow. So, some options to set this would be great.<br>
>><br>
>> I can share the data, they are from a public source.<br>
<br>
</div>For these data, GDAL can not determine the usage of the "RED",<br>
"GREEN", and "BLUE" fields, also not for the "FBFM13" field. IMHO, the<br>
best we could do is add an option to dump the raster attribute table<br>
in text format and let the user modify it such that it can be used<br>
with r.category and/or r.colors. The GDAL function to dump a raster<br>
attribute table dumps it in xml, and the documentation says itself<br>
that this is barely readable, so we would need our own dump function.<br>
<br></blockquote><div>Hi Markus,</div><div><br></div><div>I was actually dealing with this just before you started committing the attribute table related things. Since I don't know GDAL, I asked and it seems that the right thing to do is to use API [1] to generate whatever is appropriate for you (so exactly what you say). Now it seems that the best will be to forgot about CSV or XML and generate rules for colors or labels. This could be done in separate (C/Python) module based on [1] but having this as a part of r.in.gdal would be advantageous (number of parameters would be higher but you would import everything in one step).</div>
<div><br></div><div>It is possible that I will write Python module to turn attribute table into label and color rules in next weeks but I cannot promise.</div><div><br></div><div>Vaclav</div><div><br></div><div>[1] <a href="http://gis.stackexchange.com/questions/84700/how-to-show-only-raster-attribute-table-using-gdal/">http://gis.stackexchange.com/questions/84700/how-to-show-only-raster-attribute-table-using-gdal/</a></div>
<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Markus M<br>
<div class=""><div class="h5"><br>
><br>
> I would be interested.<br>
><br>
> Markus M<br>
><br>
>><br>
>> But anyway, connection to color tables and labels is great, colors and<br>
>> labels solves at least significant part of the cases where raster attribute<br>
>> tables are used.<br>
>><br>
>> Vaclav<br>
>><br>
>><br>
>> On Fri, Feb 21, 2014 at 11:26 AM, Moritz Lennert<br>
>> <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>
>>><br>
>>> On 21/02/14 17:12, Markus Metz wrote:<br>
>>>><br>
>>>> On Fri, Feb 21, 2014 at 2:00 PM, Moritz Lennert<br>
>>>> <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>
>>>>><br>
>>>>> On 21/02/14 11:30, Markus Metz wrote:<br>
>>>>>><br>
>>>>>><br>
>>>>>> On Fri, Feb 21, 2014 at 9:35 AM, Moritz Lennert<br>
>>>>>> <<a href="mailto:mlennert@club.worldonline.be">mlennert@club.worldonline.be</a>> wrote:<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> On 20/02/14 22:14, Markus Metz wrote:<br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>><br>
>>>>>>>> I would not replace a working gdal version with a probably not<br>
>>>>>>>> working<br>
>>>>>>>> gdal version. Your gdalinfo reported a raster attribute table, not<br>
>>>>>>>> mine. You could double-check again if your gdalinfo still finds a<br>
>>>>>>>> raster attribute table, then import with r.in.gdal.<br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>><br>
>>>>>>> Out of curiosity: if a table contains several columns which one(s)<br>
>>>>>>> is/are<br>
>>>>>>> imported and in what form do they appear in GRASS (I don't have a file<br>
>>>>>>> here<br>
>>>>>>> to test myself) ?<br>
>>>>>><br>
>>>>>><br>
>>>>>><br>
>>>>>> Each column has a dedicated usage. For "name" usage, the column is<br>
>>>>>> treated as category labels. For any of the color usages, the column is<br>
>>>>>> treated as corresponding red, green, or blue color. See also the gdal<br>
>>>>>> documentation [0]. Currently, r.out.gdal exports category labels or<br>
>>>>>> color rules to a raster attribute table with the new -t flag, and<br>
>>>>>> r.in.gdal automatically imports any information it finds.<br>
>>>>>><br>
>>>>>> Markus M<br>
>>>>>><br>
>>>>>> [0] <a href="http://www.gdal.org/gdal_8h.html#a27bf786b965d5227da1acc2a4cab69a1" target="_blank">http://www.gdal.org/gdal_8h.html#a27bf786b965d5227da1acc2a4cab69a1</a><br>
>>>>><br>
>>>>><br>
>>>>><br>
>>>>> So, IIUC you get the GFU_Name and the color information, but if the<br>
>>>>> table<br>
>>>>> contains several fields (which I guess will be of type GFU_Generic)<br>
>>>>> these<br>
>>>>> are ignored ?<br>
>>>><br>
>>>><br>
>>>> GFU_Generic usage is ignored because it is unknown what this could be<br>
>>>> good for.<br>
>>><br>
>>><br>
>>> VAT tables allow as many fields as the user wants, not only a class name.<br>
>>> But I don't know (and can't tell from ESRI's documentation) whether these<br>
>>> additional fields will all be considered GFU_Names or GFU_Generics) and as I<br>
>>> don't have relevant data here (and data that colleagues created for me<br>
>>> causes an error with gdal...) I can't test this at this stage.<br>
>>><br>
>>> My question was: if a raster has several fields as in the attribute table,<br>
>>> would it be possible to chose the field to use as labels in GRASS ?<br>
>>><br>
>>> Moritz<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> grass-user mailing list<br>
>>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
>>> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
>><br>
>><br>
</div></div></blockquote></div><br></div></div>