@Override
 public void decode(ProfileReadContext ctx, Product p) throws IOException {
   final Band[] bands = p.getBands();
   for (Band band : bands) {
     String variableName = ReaderUtils.getVariableName(band);
     final Variable variable = ctx.getNetcdfFile().getRootGroup().findVariable(variableName);
     final IndexCoding indexCoding = readIndexCoding(variable, band.getName() + "_index_coding");
     if (indexCoding != null) {
       p.getIndexCodingGroup().add(indexCoding);
       band.setSampleCoding(indexCoding);
     }
   }
 }
  private static ImageInfo createIndexedImageInfo(
      Product product, TIFFRenderedImage baseImage, Band band) {
    final IndexColorModel colorModel = (IndexColorModel) baseImage.getColorModel();
    final IndexCoding indexCoding = new IndexCoding("color_map");
    final int colorCount = colorModel.getMapSize();
    final ColorPaletteDef.Point[] points = new ColorPaletteDef.Point[colorCount];
    for (int j = 0; j < colorCount; j++) {
      final String name = String.format("I%3d", j);
      indexCoding.addIndex(name, j, "");
      points[j] = new ColorPaletteDef.Point(j, new Color(colorModel.getRGB(j)), name);
    }
    product.getIndexCodingGroup().add(indexCoding);
    band.setSampleCoding(indexCoding);

    return new ImageInfo(new ColorPaletteDef(points, points.length));
  }