Skip to content

Instantly share code, notes, and snippets.

@craigds
Created November 7, 2010 20:42
Show Gist options
  • Save craigds/666564 to your computer and use it in GitHub Desktop.
Save craigds/666564 to your computer and use it in GitHub Desktop.
(not working yet)
Index: alg/gdalwarper.cpp
===================================================================
--- alg/gdalwarper.cpp (revision 21094)
+++ alg/gdalwarper.cpp (working copy)
@@ -32,6 +32,7 @@
#include "cpl_minixml.h"
#include "ogr_api.h"
#include "gdal_priv.h"
+#include <iostream>
CPL_CVSID("$Id$");
@@ -159,7 +160,14 @@
GDALRasterBandH hBand = GDALGetRasterBand( hSrcDS, iBand+1 );
int bGotNoData = FALSE;
double dfNoDataValue;
-
+
+ std::cout << "band " << iBand << " interpretation: " << GDALGetRasterColorInterpretation(hBand) << "\n";
+
+ if (GDALGetRasterColorInterpretation(hBand) == GCI_AlphaBand)
+ {
+ psWOptions->nSrcAlphaBand = iBand + 1;
+ }
+
dfNoDataValue = GDALGetRasterNoDataValue( hBand, &bGotNoData );
if( bGotNoData )
{
Index: swig/python/scripts/gdal_retile.py
===================================================================
--- swig/python/scripts/gdal_retile.py (revision 21094)
+++ swig/python/scripts/gdal_retile.py (working copy)
@@ -165,6 +165,11 @@
self.ct = ct.Clone()
else:
self.ct = None
+ self.ci = [0] * self.bands
+ for iband in range(self.bands):
+ ci = fhInputTile.GetRasterBand(iband + 1).GetColorInterpretation()
+ self.ci[iband] = ci
+ print "1. band=%s, ci=%s" % (iband+1, ci)
extent = self.ogrTileIndexDS.GetLayer().GetExtent()
self.ulx = extent[0];
@@ -428,10 +433,13 @@
t_fh.SetGeoTransform( geotransform )
t_fh.SetProjection( levelMosaicInfo.projection)
- if levelMosaicInfo.ct is not None:
- for band in range(1,bands+1):
- t_band = t_fh.GetRasterBand( band )
+ for band in range(1,bands+1):
+ t_band = t_fh.GetRasterBand( band )
+ if levelMosaicInfo.ct is not None:
t_band.SetRasterColorTable(levelMosaicInfo.ct)
+ ci = levelMosaicInfo.ci[band-1]
+ print "2. band=%s, ci=%s" % (band, ci)
+ t_band.SetRasterColorInterpretation(ci)
res = gdal.ReprojectImage(s_fh,t_fh,None,None,ResamplingMethod)
if res!=0:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment