Raster Resampling¶
Classic rendering
This page is about the classic rendering path: layers drawn by a LayerOverlay. On a map drawn from a style document (GpuBasemap and MapStyle), a raster layer is resampled the way its RasterPaint says: RasterResampling.Auto (the default from ThinkGeo 15.1), Linear or Nearest, the style spec's raster-resampling. Basemaps has the details.
style.AddRaster(tiles, new RasterPaint(1f, resampling: RasterResampling.Nearest));
A tile or an image is rarely drawn at exactly its own size. Whenever it is scaled, ThinkGeo picks a resampling method from what the layer holds. A land-use raster must stay blocky, or its classes bleed into colors that mean nothing. A street map must stay crisp, or its labels blur. A satellite photo must be smooth, or it shimmers as you zoom.
Here is a land-use raster drawn at about 15 times its own size, first with NearestNeighbor, then with Auto, the default for a raster that does not say what it holds:

Content Types¶
Every layer and raster source reports a RasterContentType, and the content type picks the default RasterResamplingMode.
RasterContentType | Example | What it holds | Default RasterResamplingMode |
|---|---|---|---|
CategoricalRaster | ![]() | Discrete classes: land use, zones, warning areas. | NearestNeighbor |
CartographicTiles | ![]() | Street maps, with lines and labels. | CartographicAuto |
Imagery | ![]() | Satellite, aerial and drone photos. | Auto |
ContinuousRaster | ![]() | Smooth gradients: hillshades, heat maps. | Auto |
Unspecified | Nothing reported. | Auto |
How Each Mode Samples¶
NearestNeighbor, Bilinear, Trilinear (bilinear with mipmaps) and Bicubic (Mitchell) always sample the same way. Auto and CartographicAuto look at how much the image is scaled:
| Scale (drawn size / image size) | Auto | CartographicAuto |
|---|---|---|
| Above 1.05 | Bicubic | Bicubic |
| 1.0 to 1.05 | Bicubic | Nearest |
| 0.95 to 1.0 | Trilinear | Nearest |
| Below 0.95 | Trilinear | Trilinear |
CartographicAuto draws a tile at nearly its own size pixel for pixel, so lines and labels stay sharp. A tile is often scaled by a fraction of a percent, and without the 5% margin that would blur it.
Which Layers Report What¶
GridFeatureLayerisCategoricalRaster.FeatureLayerisContinuousRasterwhen it has aHeatStyle, otherwiseCartographicTiles.- Online maps that offer both street and aerial maps report
ImageryorCartographicTilesdepending on the map type:ThinkGeoRasterMapsAsyncLayer,BingMapsAsyncLayer,GoogleMapsAsyncLayer,GoogleMapTilesAsyncLayer,HereMapsRasterTileAsyncLayer,MapBoxStaticTilesAsyncLayerandAzureMapsRasterAsyncLayer. Azure Maps weather tiles areContinuousRaster. - The other online and service layers are
CartographicTiles:OpenStreetMapAsyncLayer,ThinkGeoVectorMapsAsyncLayer,MvtTilesAsyncLayer,WmsAsyncLayer,WmtsAsyncLayer,ArcGisServerRestAsyncLayer, the WFS and OGC API layers, and so on. - A raster layer reports what its raster source reports.
GeoTiffRasterSource,SkiaRasterSource, the GDAL sources andWpfRasterSourcereportUnspecified, so they draw withAuto. The GDAL sources read the file with their ownResamplingAlgorithmfirst, below.
Changing It¶
Set the Mode on a GeoTIFF or Skia Raster¶
GeoTiffRasterLayer, SkiaRasterLayer and their sources have a ResamplingMode property. Anything other than Auto is used as it is, whatever the content type:
var layer = new GeoTiffRasterLayer("landuse.tif");
layer.ResamplingMode = RasterResamplingMode.NearestNeighbor;
A GeoTIFF of a scanned street map would use RasterResamplingMode.CartographicAuto instead.
The GDAL sources read through GDAL, whose ResamplingAlgorithm picks the method: nearest neighbor by default, bilinear for a source that reports Imagery or ContinuousRaster.
var source = new GeoTiffGdalRasterSource("landuse.tif");
source.ResamplingAlgorithm = RIOResampleAlg.GRIORA_NearestNeighbour;
Report a Different Content Type¶
Other layers and sources take their mode from the content type, so override GetRasterContentTypeCore(). On a feature layer, override it on the layer:
public class LandUseLayer : ShapeFileFeatureLayer
{
protected override RasterContentType GetRasterContentTypeCore()
=> RasterContentType.CategoricalRaster;
}
A raster layer always reports what its source reports, so override it on the raster source:
public class LandUseRasterSource : GeoTiffRasterSource
{
public LandUseRasterSource(string path) : base(path) { }
protected override RasterContentType GetRasterContentTypeCore()
=> RasterContentType.CategoricalRaster;
}
Reprojected Rasters¶
Reprojecting a raster resamples it too. From ThinkGeo 15.1 the setting holds through it; before, a reprojected raster was always blended, whatever it was set to.
- A source with a
GdalProjectionConverterreprojects with nearest neighbor when its mode isNearestNeighbor, and with cubic otherwise. - A
GdalRasterSourcewith aWarpProjectionwarps with theResamplingAlgorithmset before it opens. Left unset, a source that reportsCategoricalRasterwarps with nearest neighbor and any other with bilinear.
Anti-Aliasing¶
Anti-aliasing is set for a whole overlay, not per layer, so that every layer on a tile has the same edges. DrawingQuality is the short way to set it:
DrawingQuality | Images | Lines and polygons | Text | Polygon seam sealing |
|---|---|---|---|---|
Standard (default) | Off | On | On | On, not anti-aliased |
HighSpeed | Off | Off | Off | Off |
DrawingQuality does not change resampling. Default, Medium and HighQuality are compile errors in ThinkGeo 15; use Standard.
DrawingQuality is a preset: setting it replaces the overlay's RenderingOptions. For finer control, set RenderingOptions directly, after any DrawingQuality:
layerOverlay.RenderingOptions = new RenderingOptions(
imageAntiAlias: false,
vectorAntiAlias: true,
textAntiAlias: true,
PolygonSeamRenderingMode.SeamWithAntiAlias);
When you draw on a SkiaGeoCanvas yourself, set its RenderingOptions the same way.



