ThinkGeo.com    |     Documentation    |     Premium Support

Raster image Coloring

How to color the raster layer baseed on the different cell value

Hi Palani,

Please let us know your detail data format.

Regards,

Don

Dear Don,

Its .jpeg or .png file.

Hi Palani,

Thanks for your reply, we hadn’t support the color the PNG and JPEG files based on the different cell value.

But thanks to let us know your requirement, I will let our development team know that.

Regards,

Don

Dear Don ,

Thanks for your reply i have used the RasterLayer.ColorMapping.Add, for color to rasterlayer. i have got the results also its working fine.

i will add the code below.

first color is key color of our image and second color is value color. we are changing the color based on our requirement.

private void applyColorForRasterLayer(GdiPlusRasterLayer i_RasterLayer)
{
for (int i = 0; i < 256; i++)
{
if (i > 0 && i <= 130)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#fdfdfc"));
}
else if (i > 130 && i <= 155)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#fdfdfc"));
}
else if (i > 155 && i <= 180)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#54ab47"));
}
else if (i > 180 && i <= 205)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#fdfb2a"));
}
else if (i > 205 && i <= 230)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#fdae2a"));
}
else if (i > 230 && i <= 255)
{
i_RasterLayer.ColorMappings.Add(GeoColor.FromArgb(255, i, i, i), GeoColor.FromHtml("#f60736"));
}
i_RasterLayer.Transparency = 10;
}
}


this is my key image
blcak and wite images

this is my Value image

1 Like

Hi Palani,

Thank you for let us know that,

It is really a great pertinent example for ColorMapping.

Any questions please feel free to let us know.

Thanks again,

Emil

1 Like