Le dimanche 18 mai 2014 17:55:49, kalu671 a écrit : > I have a reference raster map and list of other rasters. I want to get > color table from reference map and set to the list using python. I can > read other parameters from raster but some how I can not get the color > table > (GetRasterColorTable())from the source file, let alone setting the table > (SetRasterColorTable())to the list. I am pasting some code lines here. > Could someone help me figuring this out? or suggesting another easy > solution? > > There is another similar thread but that is related to C#. I tried to > follow that in python but didn't help. > > SourceFile = "source.tif" > targetFile = "target.tif" > > rastDriver = gdal.GetDriverByName('gtiff') > rastDriver.Register() > > inSourceFile = gdal.Open(SourceFile) > inTargetFile = gdal.Open(targetFile) > > ## reading parameters of source file > col = inSourceFile.RasterXSize > row = inSourceFile.RasterYSize > bands = inSourceFile.RasterCount > ct = inSourceFile.GetRasterColorTable() # the code stops working
--> Color tables are attached to bands, not datasets. so you have to do something like inSourcefile.GetRasterBand(1).GetRasterColorTable() > from this line if I comment out this line the code goes through > GeoT = inSourceFile.GetGeoTransform() > proj = inSourceFile.GetProjection() > > > Thank you in Advance for your help > > > > > > > -- > View this message in context: > http://osgeo-org.1560.x6.nabble.com/Raster-Color-map-in-python-tp5141027.h > tml Sent from the GDAL - Dev mailing list archive at Nabble.com. > _______________________________________________ > gdal-dev mailing list > gdal-dev@lists.osgeo.org > http://lists.osgeo.org/mailman/listinfo/gdal-dev -- Geospatial professional services http://even.rouault.free.fr/services.html _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev