GDalRasterLayer recolor

Topics: Algorithms, SharpMap Project
Nov 21, 2013 at 3:05 PM
Hello all,

I'm new to Sharpmap - i'm using v.1.0.4.
I have successfully created a gdalrasterlayer with a bitonal (b/w) tif image, displayed it on a map and also set its transparentcolor to white. Now, I would like to display the tif's black color using another color e.g., gray. I guess that the Colorblend or Curvelut properties might work for me, however there is no how-to. Any suggestions?
Nov 22, 2013 at 10:14 AM
With the help of Gdal command line tools you can change the color.
gdalbuildvrt myraster.vrt myraster.tif
You get sth like this:
<VRTDataset rasterXSize="29527" rasterYSize="25984">
  <GeoTransform> 2.5895123649736401e+006, 8.4670420376497046e-001, 0.0000000000000000e+000, 5.7200398466748763e+006, 0.0000000000000000e+000,-8.4667487684729059e-001</GeoTransform>
  <VRTRasterBand dataType="Byte" band="1">
      <Entry c1="0" c2="0" c3="" c4="255" />
      <Entry c1="255" c2="255" c3="255" c4="255" />
      <SourceFilename relativeToVRT="1">myraster.tif</SourceFilename>
      <SourceProperties RasterXSize="29527" RasterYSize="25984" DataType="Byte" BlockXSize="29527" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="29527" ySize="25984" />
      <DstRect xOff="0" yOff="0" xSize="29527" ySize="25984" />
Change the entry of the color table that provides the black:
<Entry c1="0" c2="0" c3="" c4="255" /> -> <Entry c1="127" c2="127" c3="127" c4="255" />
Nov 22, 2013 at 4:15 PM
It works perfectly. Thanks!