In this tutorial, we assume that the reader is familiar with the LuciadCPillar concepts introduced in the Create your first map application tutorial:


This tutorial teaches you the basic concepts of the LuciadCPillar API for styling raster data on a LuciadCPillar map.

Apply default styling to a raster layer

The tutorial Create your first map application shows you how to create a raster layer using default styling.

Apply custom styling to a raster layer

Because the map only shows RGB(A) raster data, LuciadCPillar uses the default color model of the data.

Most raster data is suitable for display at specific scales only. For example, it makes no sense to show detailed raster data of a certain area when users have zoomed out of a map. They won’t be able to distinguish the details on the map at that point.

If the application doesn’t load that raster data when users have zoomed out, application performance increases, and it no longer needs to consume huge amounts of memory. Instead, the LuciadCPillar map shows just the geographical bounds of the raster data set when users zoom out.

When you apply the default styling of the RasterLayer::Builder, those bounds get a style that consists of a red hatch pattern. We are going to mimic that in this example by defining a line style for the outline of the bounds, and a fill style for the fill of the bounds.

Program (C++): Creating the style for the raster outline
Color fillColor = Color(255, 0, 0, 191);
Color lineColor = Color(255, 0, 0);
std::shared_ptr<luciad::Image> fillImage = StipplePattern::createImage(fillColor, StipplePattern::Hatched);
std::shared_ptr<FillStyle> fillStyle = FillStyle::newBuilder().image(fillImage).build();
std::shared_ptr<LineStyle> lineStyle = LineStyle::newBuilder().color(lineColor).width(2.0).build();
layer = RasterLayer::newBuilder().model(rasterModel).fillStyle(fillStyle).lineStyle(lineStyle).build();
Program (C#): Creating the style for the raster outline
Color fillColor = Color.FromArgb(191, 255, 0, 0);
Color lineColor = Color.FromArgb(255, 255, 0, 0);
Image fillImage = StipplePattern.CreateImage(fillColor, StipplePattern.Hatched);
FillStyle fillStyle = FillStyle.NewBuilder().Image(fillImage).Build();
LineStyle lineStyle = LineStyle.NewBuilder().Color(lineColor).Width(2.0).Build();
layer = RasterLayer.NewBuilder().Model(model as IRasterModel).FillStyle(fillStyle).LineStyle(lineStyle).Build();

On the map, this looks like:

cp rasterpainting red hatch
Figure 1. The red hatching when zoomed out, indicating the bounds of the raster data set
cp rasterpainting result
Figure 2. The actual raster data when zoomed in

See Why does my imagery layer show a red (hatched) rectangle? for more information about the red hatching pattern.