[GRASS-dev] Export of integer raster from GRASS 70 with raster attribute table shifts classes

Newcomb, Doug doug_newcomb at fws.gov
Tue Nov 25 10:54:42 PST 2014


Hi Folks,

I was running r.geomorphon,
http://grass.osgeo.org/grass70/manuals/addons/r.geomorphon.html, to
generate a landscape integer grid.  I decided to share the output with a
colleague running ArcGIS.  I exported with the raster attribute table
option to HFA ( img , int16 ) format and passed it along.  He noticed
something in the attribute table that was a bit odd.

The the output values for r.geomorphon are integer values from 1 -10 .  The
output .img file
had the following in the following output for gdalinfo ( see below)



As you can see below, a 0 value was added to the color table and the
class_names start at 0 and not at 1 ( i.e, flat=0, but flat should equal 1)
 .  The pixel values do not change, the class names in the
GDALRasterAttributeTable  are are associated  with a lower pixel value
(shifted down one value.1--->0 and so on)

Exporting via r.out.gdal to the same file format without a raster attribute
table or a color table gave a raster with values of 1-10.

running gdal 1.11.1 on ubuntu  12.04 with GRASS 7.0 snapshot 2014_10_25.

Not sure if it's a  grass or gdal issue

gdalinfo output:

-----------------------------------------------------------------------------------

Driver: HFA/Erdas Imagine Images (.img)
Files: NED_SoApp_forms_cell25.img
       NED_SoApp_forms_cell25.img.aux.xml
Size is 22854, 12004
Coordinate System is:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
Origin = (-86.094722219722215,37.848055555000002)
Pixel Size = (0.000277777777802,-0.000277777777801)
Corner Coordinates:
Upper Left  ( -86.0947222,  37.8480556) ( 86d 5'41.00"W, 37d50'53.00"N)
Lower Left  ( -86.0947222,  34.5136111) ( 86d 5'41.00"W, 34d30'49.00"N)
Upper Right ( -79.7463889,  37.8480556) ( 79d44'47.00"W, 37d50'53.00"N)
Lower Right ( -79.7463889,  34.5136111) ( 79d44'47.00"W, 34d30'49.00"N)
Center      ( -82.9205556,  36.1808333) ( 82d55'14.00"W, 36d10'51.00"N)
Band 1 Block=64x64 Type=Int16, ColorInterp=Palette
  Description = Layer_1
  NoData Value=-32768
  Metadata:
    COLOR_TABLE_RULE_RGB_0=1.000000e+00 1.000000e+00 220 220 220 220 220 220
    COLOR_TABLE_RULE_RGB_10=1.100000e+01 1.100000e+01 255 0 255 255 0 255
    COLOR_TABLE_RULE_RGB_1=2.000000e+00 2.000000e+00 56 0 0 56 0 0
    COLOR_TABLE_RULE_RGB_2=3.000000e+00 3.000000e+00 200 0 0 200 0 0
    COLOR_TABLE_RULE_RGB_3=4.000000e+00 4.000000e+00 255 80 20 255 80 20
    COLOR_TABLE_RULE_RGB_4=5.000000e+00 5.000000e+00 250 210 60 250 210 60
    COLOR_TABLE_RULE_RGB_5=6.000000e+00 6.000000e+00 255 255 60 255 255 60
    COLOR_TABLE_RULE_RGB_6=7.000000e+00 7.000000e+00 180 230 20 180 230 20
    COLOR_TABLE_RULE_RGB_7=8.000000e+00 8.000000e+00 60 250 150 60 250 150
    COLOR_TABLE_RULE_RGB_8=9.000000e+00 9.000000e+00 0 0 255 0 0 255
    COLOR_TABLE_RULE_RGB_9=1.000000e+01 1.000000e+01 0 0 56 0 0 56
    COLOR_TABLE_RULES_COUNT=11
    Generated_with=GRASS GIS 7.0.0svn
    LAYER_TYPE=athematic
  Image Structure Metadata:
    COMPRESSION=RLE
  Color Table (RGB with 11 entries)
    0: 0,0,0,0
    1: 220,220,220,255
    2: 56,0,0,255
    3: 200,0,0,255
    4: 255,80,20,255
    5: 250,210,60,255
    6: 255,255,60,255
    7: 180,230,20,255
    8: 60,250,150,255
    9: 0,0,255,255
   10: 0,0,56,255
<GDALRasterAttributeTable Row0Min="0" BinSize="1">
  <FieldDefn index="0">
    <Name>Red</Name>
    <Type>0</Type>
    <Usage>6</Usage>
  </FieldDefn>
  <FieldDefn index="1">
    <Name>Green</Name>
    <Type>0</Type>
    <Usage>7</Usage>
  </FieldDefn>
  <FieldDefn index="2">
    <Name>Blue</Name>
    <Type>0</Type>
    <Usage>8</Usage>
  </FieldDefn>
  <FieldDefn index="3">
    <Name>Opacity</Name>
    <Type>0</Type>
    <Usage>9</Usage>
  </FieldDefn>
  <FieldDefn index="4">
    <Name>min</Name>
    <Type>0</Type>
    <Usage>0</Usage>
  </FieldDefn>
  <FieldDefn index="5">
    <Name>max</Name>
    <Type>0</Type>
    <Usage>0</Usage>
  </FieldDefn>
  <FieldDefn index="6">
    <Name>Class_Names</Name>
    <Type>2</Type>
    <Usage>2</Usage>
  </FieldDefn>
  <Row index="0">
    <F>0</F>
    <F>0</F>
    <F>0</F>
    <F>0</F>
    <F>1</F>
    <F>1</F>
    <F>flat</F>
  </Row>
  <Row index="1">
    <F>220</F>
    <F>220</F>
    <F>220</F>
    <F>255</F>
    <F>2</F>
    <F>2</F>
    <F>summit</F>
  </Row>
  <Row index="2">
    <F>56</F>
    <F>0</F>
    <F>0</F>
    <F>255</F>
    <F>3</F>
    <F>3</F>
    <F>ridge</F>
  </Row>
  <Row index="3">
    <F>200</F>
    <F>0</F>
    <F>0</F>
    <F>255</F>
    <F>4</F>
    <F>4</F>
    <F>shoulder</F>
  </Row>
  <Row index="4">
    <F>255</F>
    <F>80</F>
    <F>20</F>
    <F>255</F>
    <F>5</F>
    <F>5</F>
    <F>spur</F>
  </Row>
  <Row index="5">
    <F>250</F>
    <F>210</F>
    <F>60</F>
    <F>255</F>
    <F>6</F>
    <F>6</F>
    <F>slope</F>
  </Row>
  <Row index="6">
    <F>255</F>
    <F>255</F>
    <F>60</F>
    <F>255</F>
    <F>7</F>
    <F>7</F>
    <F>hollow</F>
  </Row>
  <Row index="7">
    <F>180</F>
    <F>230</F>
    <F>20</F>
    <F>255</F>
    <F>8</F>
    <F>8</F>
    <F>footslope</F>
  </Row>
  <Row index="8">
    <F>60</F>
    <F>250</F>
    <F>150</F>
    <F>255</F>
    <F>9</F>
    <F>9</F>
    <F>valley</F>
  </Row>
  <Row index="9">
    <F>0</F>
    <F>0</F>
    <F>255</F>
    <F>255</F>
    <F>10</F>
    <F>10</F>
    <F>depression</F>
  </Row>
  <Row index="10">
    <F>0</F>
    <F>0</F>
    <F>56</F>
    <F>255</F>
    <F>11</F>
    <F>11</F>
    <F>ERROR</F>
  </Row>
</GDALRasterAttributeTable>


-- 
Doug Newcomb
USFWS
Raleigh, NC
919-856-4520 ext. 14 doug_newcomb at fws.gov
---------------------------------------------------------------------------------------------------------
The opinions I express are my own and are not representative of the
official policy of the U.S.Fish and Wildlife Service or Dept. of the
Interior.   Life is too short for undocumented, proprietary data formats.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20141125/63a92bdd/attachment.html>


More information about the grass-dev mailing list