Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-04 Thread mhw-at-yg
> You could also potentially use a raster attribute table. See
> GDALRasterAttributeTable in https://gdal.org/drivers/raster/vrt.html

Yeah, loose is right. ;-)  This is what I think I've puzzled out:


 



would be expressed as:




Type 2 means it's a string (GFT_String)
Usage 2 means this is the name of the class (GFU_Name)

Type 0 means a non-decimal number (GFT_Integer)
Usage 5 means use for pixels matching this value from the intersecting row
(GFU_MinMax)

Am I on the right track?

-Matt



-
-Matt
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-04 Thread Even Rouault
On vendredi 4 octobre 2019 12:44:18 CEST mhw-at-yg wrote:
> > I don't see VRT cascading of any help here, from what I've understood of
> 
> your
> 
> > use case. I think you have no other choice than replicating  and
> >  in all 
> 
> Ok. Thanks for confirming my understanding.
> 
> Next question: It appears that   are order-of-index
> based. Meaning that: if "Evergreen" is first element in the category list it
> is matched to the first element in the color list. So there is no way in
> vrt to specify a lookup table of style "name == pixel_value" like the
> below?
> 
>   Pixel_Value   Category
>  - --
> 1   Evergreen Forest
> 2   Deciduous Forest
>   ...
>14   Barren
>15   Water
> 
> 
> I've worked around this by inserting an "n/a" category and 0,0,0 colour
> table as first line in each. Without that in qgis and arcmap everything is
> shifted by one and 'Deciduous' is assigned to pixel value 1 and 'Water' to
> 14.
> 

You could also potentially use a raster attribute table. See 
GDALRasterAttributeTable in https://gdal.org/drivers/raster/vrt.html
The documentation is a bit loose.
The values for Type and Usage match the enumerations at
https://github.com/OSGeo/gdal/blob/master/gdal/gcore/gdal.h#L1189

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-04 Thread mhw-at-yg
> I don't see VRT cascading of any help here, from what I've understood of
your 
> use case. I think you have no other choice than replicating  and 
>  in all 

Ok. Thanks for confirming my understanding.

Next question: It appears that   are order-of-index
based. Meaning that: if "Evergreen" is first element in the category list it
is matched to the first element in the color list. So there is no way in vrt
to specify a lookup table of style "name == pixel_value" like the below?

  Pixel_Value   Category  
 - -- 
1   Evergreen Forest  
2   Deciduous Forest  
  ... 
   14   Barren
   15   Water   


I've worked around this by inserting an "n/a" category and 0,0,0 colour
table as first line in each. Without that in qgis and arcmap everything is
shifted by one and 'Deciduous' is assigned to pixel value 1 and 'Water' to
14.

-Matt





-
-Matt
--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-04 Thread Even Rouault
On vendredi 4 octobre 2019 08:25:49 CEST mhw-at-yg wrote:
> > Have you tried create a cascading VRT, where the first VRT composites
> > all the GTiff files into a single virtual raster and then reference the
> > composite in another VRT that assigns colortable.
> 
> Hmm, I hadn't thought about cascading; didn't know that was possible. I'd
> still need 31 vrt's though right? 1 for each band.

I don't see VRT cascading of any help here, from what I've understood of your 
use case. I think you have no other choice than replicating  and 
 in all 

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-04 Thread mhw-at-yg
> Have you tried create a cascading VRT, where the first VRT composites 
> all the GTiff files into a single virtual raster and then reference the 
> composite in another VRT that assigns colortable.

Hmm, I hadn't thought about cascading; didn't know that was possible. I'd
still need 31 vrt's though right? 1 for each band.  

-Matt




--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-03 Thread Stephen Woodbridge

Matt,

Have you tried create a cascading VRT, where the first VRT composites 
all the GTiff files into a single virtual raster and then reference the 
composite in another VRT that assigns colortable. I think this should 
work nicely.


-Steve W

On 10/3/2019 7:01 PM, matt.wil...@gov.yk.ca wrote:


Hello gdal-dev, it's been a long time!  I'm happy to be digging into 
raster data building again for a change, but could use some nudges in 
the right direction(s).


A few weeks ago Nasa released Landsat-derived Annual Dominant Land 
Cover Across ABoVE Core Domain, 1984-2014 
.


It’s composed of 175 geotiff images, with each file containing 31 
bands which in turn correspond to a single year in the 1984-2014 
period. Each band is 8bit unsigned integer with values from 1 to 15 
and 255 as nodata. Each integer value corresponds to a class such as 
“Evergreen Forest”, “Herbaceous”, “Water” and so on.


I’ve been successful in manually building a VRT file using Category 
element for the classes and ColorTable entry for a palette – but only 
for a single band.


My question is: how to properly apply this to all bands? Do I need 
duplicate category and colortable elements to every single 
VRTRasterBand element or is there a smart way to define it once and 
then refer to it like a variable?  Am I even approaching this the 
right way?


It was quite a bit of work to get this far and I’m not looking forward 
to doing this 30 more times.


Sample vrt and simplified source is attached.

*Matt Wilkie*

Geomatics Analyst

Environment | Information Management & Technology

T 867-667-8133 | Yukon.ca 


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] vrt guidance: 31 band classified raster

2019-10-03 Thread Matt.Wilkie
> It was quite a bit of work to get this far and I'm not looking forward to 
> doing this 30 more times.

On this point, discovery of the day is Easy XML 
Editor which allows editing some 
attributes as if in a spreadsheet. It's alleviated much difficulty, but is 
still finicky.

-Matt
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

[gdal-dev] vrt guidance: 31 band classified raster

2019-10-03 Thread Matt.Wilkie
Hello gdal-dev, it's been a long time!  I'm happy to be digging into raster 
data building again for a change, but could use some nudges in the right 
direction(s).

A few weeks ago Nasa released Landsat-derived Annual Dominant Land Cover Across 
ABoVE Core Domain, 
1984-2014.

It's composed of 175 geotiff images, with each file containing 31 bands which 
in turn correspond to a single year in the 1984-2014 period. Each band is 8bit 
unsigned integer with values from 1 to 15 and 255 as nodata. Each integer value 
corresponds to a class such as "Evergreen Forest", "Herbaceous", "Water" and so 
on.

I've been successful in manually building a VRT file using Category element for 
the classes and ColorTable entry for a palette - but only for a single band.

My question is: how to properly apply this to all bands? Do I need duplicate 
category and colortable elements to every single VRTRasterBand element or is 
there a smart way to define it once and then refer to it like a variable?  Am I 
even approaching this the right way?

It was quite a bit of work to get this far and I'm not looking forward to doing 
this 30 more times.

Sample vrt and simplified source is attached.

Matt Wilkie
Geomatics Analyst
Environment | Information Management & Technology
T 867-667-8133 | Yukon.ca



scratch_manually_built.vrt
Description: scratch_manually_built.vrt
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev