Modify an image color table? -- SOLVED -- Thanks a lot Frank and Luke.
This is the solution of my problem: 1) I built *.vrt file from ASCII file; 2) I used the <LUT> command like this: ---------------------------------------------------------------------------------------------------------- <VRTRasterBand dataType="Byte" band="1"> <ColorInterp>Red</ColorInterp> <ComplexSource> <SourceFilename relativeToVRT="1">file.asc</SourceFilename> <SourceBand>1</SourceBand> <LUT> -9999:0, -31:99, -30:99, -29:99, -28:99, -27:99, -26:99, -25:99, -24:99, -23:99, -22:99, -21:99, -20:99, -19:99, -18:99, -17:99, -16:99, -15:20, -14:20, -13:20, -12:20, -11:20, -10:8, -9:8, -8:8, -7:8, -6:8, -5:5, -4:5, -3:5, -2:5, -1:5, 0:3, 1:3, 2:3, 3:3, 4:3, 5:1, 6:1, 7:1, 8:1, 9:1, 10:1, 11:1, 12:1, 13:1, 14:1, 15:30, 16:30, 17:30, 18:30, 19:30, 20:52, 21:52, 22:52, 23:52, 24:52, 25:72, 26:72, 27:72, 28:72, 29:72, 30:94, 31:94, 32:94, 33:94, 34:94, 35:100, 36:100, 37:100, 38:100, 39:100, 40:100, 41:100, 42:100, 43:100, 44:100, 45:100, 46:100, 47:100, 48:100, 49:100, 50:100, 51:100, 52:100, 53:100, 54:100, 55:100, 56:100, 57:100, 58:100, 59:100, 60:90, 61:90, 62:90, 63:90, 64:90, 65:82 </LUT> </ComplexSource> </VRTRasterBand> <VRTRasterBand dataType="Byte" band="2"> <ColorInterp>Green</ColorInterp> <ComplexSource> <SourceFilename relativeToVRT="1">file.asc</SourceFilename> <SourceBand>1</SourceBand> <LUT> -9999:0, -31:99, -30:99, -29:99, -28:99, -27:99, -26:99, -25:99, -24:99, -23:99, -22:99, -21:99, -20:99, -19:99, -18:99, -17:99, -16:99, -15:8, -14:8, -13:8, -12:8, -11:8, -10:22, -9:22, -8:22, -7:22, -6:22, -5:33, -4:33, -3:33, -2:33, -1:33, 0:42, 1:42, 2:42, 3:42, 4:42, 5:60, 6:60, 7:60, 8:60, 9:60, 10:67, 11:67, 12:67, 13:67, 14:67, 15:87, 16:87, 17:87, 18:87, 19:87, 20:91, 21:91, 22:91, 23:91, 24:91, 25:95, 26:95, 27:95, 28:95, 29:95, 30:99, 31:99, 32:99, 33:99, 34:99, 35:90, 36:90, 37:90, 38:90, 39:90, 40:79, 41:79, 42:79, 43:79, 44:79, 45:65, 46:65, 47:65, 48:65, 49:65, 50:50, 51:50, 52:50, 53:50, 54:50, 55:20, 56:20, 57:20, 58:20, 59:20, 60:1, 61:1, 62:1, 63:1, 64:1, 65:1 </LUT> </ComplexSource> </VRTRasterBand> <VRTRasterBand dataType="Byte" band="3"> <ColorInterp>Blue</ColorInterp> <ComplexSource> <SourceFilename relativeToVRT="1">file.asc</SourceFilename> <SourceBand>1</SourceBand> <LUT> -9999:0, -31:99, -30:99, -29:99, -28:99, -27:99, -26:99, -25:99, -24:99, -23:99, -22:99, -21:99, -20:99, -19:99, -18:99, -17:99, -16:99, -15:69, -14:69, -13:69, -12:69, -11:69, -10:68, -9:68, -8:68, -7:68, -6:68, -5:65, -4:65, -3:65, -2:65, -1:65, 0:64, 1:64, 2:64, 3:64, 4:64, 5:60, 6:60, 7:60, 8:60, 9:60, 10:42, 11:42, 12:42, 13:42, 14:42, 15:1, 16:1, 17:1, 18:1, 19:1, 20:1, 21:1, 22:1, 23:1, 24:1, 25:1, 26:1, 27:1, 28:1, 29:1, 30:1, 31:1, 32:1, 33:1, 34:1, 35:1, 36:1, 37:1, 38:1, 39:1, 40:1, 41:1, 42:1, 43:1, 44:1, 45:1, 46:1, 47:1, 48:1, 49:1, 50:1, 51:1, 52:1, 53:1, 54:1, 55:1, 56:1, 57:1, 58:1, 59:1, 60:20, 61:20, 62:20, 63:20, 64:20, 65:43 </LUT> </ComplexSource> </VRTRasterBand> --------------------------------------------------------------------------------------------------------------------------------------------- 2010/6/25 Frank Warmerdam <warmer...@pobox.com> > Marco Stelluti wrote: > >> Hi, >> I'm a new gdal user and I've a little problem. >> >> I have to modify the color to an ASCII raster. >> >> 1_ I converted the raster using gdalbuildvrt; >> 2_ I modified the file *.vrt adding: >> <ColorInterp>Palette</ColorInterp> >> <ColorTable> >> <Entry c1="255" c2="255" c3="255" c4="255"/> >> <Entry c1="0" c2="0" c3="150" c4="255"/> >> <Entry c1="0" c2="0" c3="150" c4="255"/> >> ....... >> </ColorTable> >> 3_ I know: "The entries are ordered and will be assumed to start from >> color table entry 0" >> 4_ But I have some negative value on the ASCII raster, the range is from >> -31 to 65. >> 5_ How I can resolve this problem? >> > > Marco, > > Generally speaking GDAL color maps do not have an obvious application > to negative or non-integer data. You could use the "raster attribute > table" > mechanism to represent color assignments to negative values, but since so > few applications make use of this data object it is nearly useless to do > so. > > What application do you want the color table to work in? How you handle > the situation will depend on the output application. If preserving the > original pixel values isn't important you may want to reprocess/rescale > your > raster. > > Best regards, > -- > > ---------------------------------------+-------------------------------------- > I set the clouds in motion - turn up | Frank Warmerdam, > warmer...@pobox.com > light and sound - activate the windows | > http://pobox.com/~warmerdam<http://pobox.com/%7Ewarmerdam> > and watch the world go round - Rush | Geospatial Programmer for Rent > >
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev