[GRASS-user] r.in.gdal for importing categorical ArcGIS binary rasters

Markus Metz markus.metz.giswork at gmail.com
Thu Feb 20 13:14:11 PST 2014


On Thu, Feb 20, 2014 at 9:32 AM, manuel.martin
<manuel.martin at orleans.inra.fr> wrote:
> On 02/18/2014 09:31 PM, Markus Metz wrote:
>>
>> On Tue, Feb 18, 2014 at 2:09 PM, manuel.martin
>> <manuel.martin at orleans.inra.fr> wrote:
>>>
>>> On 02/18/2014 01:56 PM, Markus Metz wrote:
>>>>
>>>> On Tue, Feb 18, 2014 at 1:14 PM, manuel.martin
>>>> <manuel.martin at orleans.inra.fr> wrote:
>>>>>
>>>>> On 02/18/2014 12:47 PM, Markus Metz wrote:
>>>>>>
>>>>>> On Tue, Feb 18, 2014 at 11:43 AM, manuel.martin
>>>>>> <manuel.martin at orleans.inra.fr> wrote:
>>>>>>>
>>>>>>> Hi, I just compiled grass r59073 and gave a try.
>>>>>>> I could not get the attributes imported along with the raster, but
>>>>>>> maybe
>>>>>>> am
>>>>>>> I missing something from the new revision of r.in.gdal (although from
>>>>>>> the
>>>>>>> code it looks that the import of values from the attribute table
>>>>>>> should
>>>>>>> be
>>>>>>> automatic?).
>>>>>>
>>>>>> Yes, r.in.gdal automatically imports whatever it finds as color tables
>>>>>> or attribute labels.
>>>>>>
>>>>>>> Markus, I just sent you the ESRI layer I am trying to import, in case
>>>>>>> you
>>>>>>> would like to try as well.
>>>>>>
>>>>>> GDAL does not see an attribute table in the data you sent to me, thus
>>>>>> GRASS can not import any attributes. If there is really an attribute
>>>>>> table, it is not recognized by GDAL.
>>>>>
>>>>> Then maybe this is a gdal problem : I'm saying this because through the
>>>>> command gdalinfo, it looks like gdal detects an attribute table (see
>>>>> below).
>>>>>
>>>>> Cheers
>>>>>
>>>>>
>>>>> GRASS 7.0.svn (lambert93):~/tmp > gdalinfo
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4
>>>>> Driver: AIG/Arc/Info Binary Grid
>>>>> Files:
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4
>>>>
>>>> This file is missing in the archive you sent:
>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4.aux.xml
>>>>
>>>> I am pretty sure that it contains the raster attribute table.
>>>>
>>>> Markus M
>>>
>>> Sorry about that, I just sent the landforms/test_lf4.aux.xml to you, but
>>> unfortunately it does not seem to contain the raster attribute table...:
>>
>> Right. Unfortunately I can not reproduce the gdalinfo output you sent
>> previously, and as long as gdal does not see an attribute table, GRASS
>> can not import the labels in the attribute table. I use gdal 1.10.1,
>> if that helps.
>>
>> Markus M
>
> I am running GDAL 1.10.0, maybe that explains the difference. I will let you
> know when I will have 1.10.1 running if I still get the same gdalinfo
> results.

I would not replace a working gdal version with a probably not working
gdal version. Your gdalinfo reported a raster attribute table, not
mine. You could double-check again if your gdalinfo still finds a
raster attribute table, then import with r.in.gdal.

Alternatively, you can get the original corine land cover as raster
(the vector version is full of errors and tricky to clean up) and the
legend and import these.

Markus M

>
> Manuel
>
>>>
>>> GRASS 7.0.svn (lambert93):~/tmp > more
>>>
>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4.aux.xml
>>> <PAMDataset>
>>>
>>> <SRS>PROJCS["RGF_1993_Lambert_93",GEOGCS["GCS_RGF_1993",DATUM["Reseau_Geodesique_Francais_1993",SPHEROID["GRS_1980",63
>>>
>>> 78137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAM
>>>
>>> ETER["False_Easting",700000.0],PARAMETER["False_Northing",6600000.0],PARAMETER["Central_Meridian",3.0],PARAMETER["Standard_Pa
>>>
>>> rallel_1",44.0],PARAMETER["Standard_Parallel_2",49.0],PARAMETER["Latitude_Of_Origin",46.5],UNIT["Meter",1.0]]</SRS>
>>>    <PAMRasterBand band="1">
>>>      <Description>test_lf4</Description>
>>>      <Histograms>
>>>        <HistItem>
>>>          <HistMin>1</HistMin>
>>>          <HistMax>6</HistMax>
>>>          <BucketCount>256</BucketCount>
>>>          <IncludeOutOfRange>1</IncludeOutOfRange>
>>>          <Approximate>0</Approximate>
>>>
>>> <HistCounts>1313166|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|79933|0|0|0|0|0|0|0|0|0|0|0|0|0|
>>>
>>> 0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|110782|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0
>>>
>>> |0|0|0|0|0|0|0|0|0|0|42435|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|69408|0|0|0|0|0|0|0|0|0|0|0|0|0|0
>>>
>>> |0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1341719</HistCounts>
>>>        </HistItem>
>>>      </Histograms>
>>>    </PAMRasterBand>
>>> </PAMDataset>
>>>
>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/hdr.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/dblbnd.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/w001001.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/w001001x.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/sta.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/vat.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/log
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/prj.adf
>>>>>
>>>>>
>>>>> /home/manuel/Desktop/sftp/Projets/Projets/Zones-humides/base_sig/dsm_data/landforms/test_lf4/metadata.xml
>>>>> Size is 2504, 2089
>>>>> Coordinate System is:
>>>>> PROJCS["unnamed",
>>>>>       GEOGCS["Unknown datum based upon the GRS 1980 ellipsoid",
>>>>>           DATUM["Not_specified_based_on_GRS_1980_ellipsoid",
>>>>>               SPHEROID["GRS 1980",6378137,298.257222101,
>>>>>                   AUTHORITY["EPSG","7019"]],
>>>>>               AUTHORITY["EPSG","6019"]],
>>>>>           PRIMEM["Greenwich",0,
>>>>>               AUTHORITY["EPSG","8901"]],
>>>>>           UNIT["degree",0.0174532925199433,
>>>>>               AUTHORITY["EPSG","9122"]],
>>>>>           AUTHORITY["EPSG","4019"]],
>>>>>       PROJECTION["Lambert_Conformal_Conic_2SP"],
>>>>>       PARAMETER["standard_parallel_1",44],
>>>>>       PARAMETER["standard_parallel_2",49],
>>>>>       PARAMETER["latitude_of_origin",46.5],
>>>>>       PARAMETER["central_meridian",3],
>>>>>       PARAMETER["false_easting",700000],
>>>>>       PARAMETER["false_northing",6600000],
>>>>>       UNIT["METERS",1]]
>>>>> Origin = (198837.500000000000000,6808087.500000000000000)
>>>>> Pixel Size = (50.000000000000000,-50.000000000000000)
>>>>> Corner Coordinates:
>>>>> Upper Left  (  198837.500, 6808087.500) (  3d45' 3.55"W, 48d10'48.77"N)
>>>>> Lower Left  (  198837.500, 6703637.500) (  3d37'59.07"W, 47d14'36.54"N)
>>>>> Upper Right (  324037.500, 6808087.500) (  2d 4'11.49"W, 48d15'52.06"N)
>>>>> Lower Right (  324037.500, 6703637.500) (  1d58'52.06"W, 47d19'34.69"N)
>>>>> Center      (  261437.500, 6755862.500) (  2d51'32.26"W, 47d45'23.95"N)
>>>>> Band 1 Block=256x16 Type=Byte, ColorInterp=Undefined
>>>>>     Description = test_lf4
>>>>>     Min=1.000 Max=6.000
>>>>>     NoData Value=255
>>>>> <GDALRasterAttributeTable>
>>>>>     <FieldDefn index="0">
>>>>>       <Name>VALUE</Name>
>>>>>       <Type>0</Type>
>>>>>       <Usage>5</Usage>
>>>>>     </FieldDefn>
>>>>>     <FieldDefn index="1">
>>>>>       <Name>COUNT</Name>
>>>>>       <Type>0</Type>
>>>>>       <Usage>1</Usage>
>>>>>     </FieldDefn>
>>>>>     <FieldDefn index="2">
>>>>>       <Name>CLASS_NAME</Name>
>>>>>       <Type>2</Type>
>>>>>       <Usage>0</Usage>
>>>>>     </FieldDefn>
>>>>>     <Row index="0">
>>>>>       <F>1</F>
>>>>>       <F>1313166</F>
>>>>>       <F>Valleys</F>
>>>>>     </Row>
>>>>>     <Row index="1">
>>>>>       <F>2</F>
>>>>>       <F>79933</F>
>>>>>       <F>Lower Slopes</F>
>>>>>     </Row>
>>>>>     <Row index="2">
>>>>>       <F>3</F>
>>>>>       <F>110782</F>
>>>>>       <F>Gentle Slopes</F>
>>>>>     </Row>
>>>>>     <Row index="3">
>>>>>       <F>4</F>
>>>>>       <F>42435</F>
>>>>>       <F>Steep Slopes</F>
>>>>>     </Row>
>>>>>     <Row index="4">
>>>>>       <F>5</F>
>>>>>       <F>69408</F>
>>>>>       <F>Upper Slopes</F>
>>>>>     </Row>
>>>>>     <Row index="5">
>>>>>       <F>6</F>
>>>>>       <F>1341719</F>
>>>>>       <F>Ridges</F>
>>>>>     </Row>
>>>>> </GDALRasterAttributeTable>
>>>>>
>>>>>
>>>>>> Markus M
>>>>>>
>>>>>>> Thank you in advance
>>>>>>>
>>>>>>> Manuel
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On 02/17/2014 02:48 PM, Markus Metz wrote:
>>>>>>>>
>>>>>>>> On Fri, Feb 14, 2014 at 5:41 PM, manuel.martin
>>>>>>>> <manuel.martin at orleans.inra.fr> wrote:
>>>>>>>>>
>>>>>>>>> On 02/14/2014 05:08 PM, Markus Metz wrote:
>>>>>>>>>>
>>>>>>>>>> On Wed, Feb 12, 2014 at 5:05 PM, manuel.martin
>>>>>>>>>> <manuel.martin at orleans.inra.fr> wrote:
>>>>>>>>>>>
>>>>>>>>>>> Hi all,
>>>>>>>>>>>
>>>>>>>>>>> I tried to import an ArcGIS binary raster (corine land cover for
>>>>>>>>>>> the
>>>>>>>>>>> French
>>>>>>>>>>> territory) with three fields on each pixels (VALUE, COUNT and
>>>>>>>>>>> CODE_06)
>>>>>>>>>>> using
>>>>>>>>>>> the r.in.gdal command. The import works just fine, except that in
>>>>>>>>>>> the
>>>>>>>>>>> resulting raster, in GRASS, I only get one field, which seems to
>>>>>>>>>>> be
>>>>>>>>>>> the
>>>>>>>>>>> VALUE field (and not the CODE_06 field, which I am interested in,
>>>>>>>>>>> and
>>>>>>>>>>> which
>>>>>>>>>>> is a categorical field, although coded with integers).
>>>>>>>>>>
>>>>>>>>>> r.in.gdal will soon support import of category labels such as
>>>>>>>>>> those
>>>>>>>>>> stored in the CODE_06 field. You can then inspect the labels with
>>>>>>>>>> r.category. GDAL supports reading and writing of raster attribute
>>>>>>>>>> tables, so far only the color rules stored in a raster attribute
>>>>>>>>>> table
>>>>>>>>>> are imported, but I plan to add import of labels to r.in.gdal.
>>>>>>>>>> Note
>>>>>>>>>> that this applies only to GRASS 7.
>>>>>>>>>>
>>>>>>>>>> Markus M
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Good to hear that ;-). I will wait for the next release of
>>>>>>>>> r.in.gdal
>>>>>>>>
>>>>>>>> Done in r59073.
>>>>>>>>
>>>>>>>> Markus M
>>>>>>>>
>>>>>>>>
>>>>>>>>> (meanwhile I did import clc vector layers with v.in.ogr and later
>>>>>>>>> managed
>>>>>>>>> the category labels with v.to.rast).
>>>>>>>>>
>>>>>>>>> All the best,           Manuel
>>>>>>>>>
>>>>>>>>>>> Is there a way to produce a resulting raster with all the fields
>>>>>>>>>>> of
>>>>>>>>>>> the
>>>>>>>>>>> initial ArcGIS layer, or alternatively to choose one unique
>>>>>>>>>>> field?
>>>>>>>>>>> Also,
>>>>>>>>>>> is
>>>>>>>>>>> there a limitation on categorical fields. For instance, what if
>>>>>>>>>>> instead
>>>>>>>>>>> of
>>>>>>>>>>> integer corine land cover codes I have literal labels, i.e.
>>>>>>>>>>> levels
>>>>>>>>>>> of
>>>>>>>>>>> my
>>>>>>>>>>> categorical field coded with strings?
>>>>>>>>>>>
>>>>>>>>>>> Cheers, Manuel
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>>
>>>>>>>>>>> ----------------0----0------
>>>>>>>>>>> INRA - InfoSol
>>>>>>>>>>> Centre de recherche d'Orléans
>>>>>>>>>>> 2163 Avenue de la Pomme de Pin
>>>>>>>>>>> CS 40001 ARDON
>>>>>>>>>>> 45075 ORLEANS Cedex 2
>>>>>>>>>>> tel : (33) (0)2 38 41 48 21
>>>>>>>>>>> fax : (33) (0)2 38 41 78 69
>>>>>>>>>>> http://www.gissol.fr
>>>>>>>>>>> ----0----0------------------
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> grass-user mailing list
>>>>>>>>>>> grass-user at lists.osgeo.org
>>>>>>>>>>> http://lists.osgeo.org/mailman/listinfo/grass-user
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>> ----------------0----0------
>>>>>>>>> INRA - InfoSol
>>>>>>>>> Centre de recherche d'Orléans
>>>>>>>>> 2163 Avenue de la Pomme de Pin
>>>>>>>>> CS 40001 ARDON
>>>>>>>>> 45075 ORLEANS Cedex 2
>>>>>>>>> tel : (33) (0)2 38 41 48 21
>>>>>>>>> fax : (33) (0)2 38 41 78 69
>>>>>>>>> http://www.gissol.fr
>>>>>>>>> ----0----0------------------
>>>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> ----------------0----0------
>>>>>>> INRA - InfoSol
>>>>>>> Centre de recherche d'Orléans
>>>>>>> 2163 Avenue de la Pomme de Pin
>>>>>>> CS 40001 ARDON
>>>>>>> 45075 ORLEANS Cedex 2
>>>>>>> tel : (33) (0)2 38 41 48 21
>>>>>>> fax : (33) (0)2 38 41 78 69
>>>>>>> http://www.gissol.fr
>>>>>>> ----0----0------------------
>>>>>>>
>>>>> --
>>>>>
>>>>> ----------------0----0------
>>>>> INRA - InfoSol
>>>>> Centre de recherche d'Orléans
>>>>> 2163 Avenue de la Pomme de Pin
>>>>> CS 40001 ARDON
>>>>> 45075 ORLEANS Cedex 2
>>>>> tel : (33) (0)2 38 41 48 21
>>>>> fax : (33) (0)2 38 41 78 69
>>>>> http://www.gissol.fr
>>>>> ----0----0------------------
>>>>>
>>>
>>> --
>>>
>>> ----------------0----0------
>>> INRA - InfoSol
>>> Centre de recherche d'Orléans
>>> 2163 Avenue de la Pomme de Pin
>>> CS 40001 ARDON
>>> 45075 ORLEANS Cedex 2
>>> tel : (33) (0)2 38 41 48 21
>>> fax : (33) (0)2 38 41 78 69
>>> http://www.gissol.fr
>>> ----0----0------------------
>>>
>
>
> --
>
> ----------------0----0------
> INRA - InfoSol
> Centre de recherche d'Orléans
> 2163 Avenue de la Pomme de Pin
> CS 40001 ARDON
> 45075 ORLEANS Cedex 2
> tel : (33) (0)2 38 41 48 21
> fax : (33) (0)2 38 41 78 69
> http://www.gissol.fr
> ----0----0------------------
>


More information about the grass-user mailing list