> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/maps/llms.txt)

# Raster Colorization

![Raster colorization using raster-color.](https://docs.mapbox.com/android/assets/ideal-img/maps-examples-raster-colorization.911a98a.480.png)

This example demonstrates how to implement raster colorization using the [`rasterColor`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps.extension.style.layers.generated/-raster-layer-dsl/raster-color.html) property in **Mapbox Maps SDK for Android**.

The code below loads a custom style containing terrain type data and creates a raster layer with `rasterColor`.

A raster layer made with `rasterColor` creates the layer by coloring the pixels across the layer. In this example, we color the layer by using the [interpolate](https://docs.mapbox.com/style-spec/reference/expressions/#interpolate) function to set color values based on the terrain type (yellow for desert, green for forest etc.) across the map.

> **Note: Android Examples App Available**
> 
> This example code is part of the **Maps SDK for Android Examples App**, a working Android project [available on GitHub](https://github.com/mapbox/mapbox-maps-android/tree/v11.33.0/). Android developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
> 
> See our [Run the Maps SDK for Android Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-android-examples-app/) tutorial for step-by-step instructions.

**Kotlin**

Title: `RasterColorizationActivity.kt`

[View on GitHub](https://github.com/mapbox/mapbox-maps-android/blob/v11.33.0/app/src/main/java/com/mapbox/maps/testapp/examples/style/RasterColorizationActivity.kt)

```kt
package com.mapbox.maps.testapp.examples.style

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.maps.MapView
import com.mapbox.maps.extension.style.expressions.dsl.generated.interpolate
import com.mapbox.maps.extension.style.expressions.generated.Expression
import com.mapbox.maps.extension.style.layers.generated.backgroundLayer
import com.mapbox.maps.extension.style.layers.generated.rasterLayer
import com.mapbox.maps.extension.style.sources.generated.rasterSource
import com.mapbox.maps.extension.style.style

/**
 * Example of raster colorization using raster-color property.
 */
class RasterColorizationActivity : AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val mapView = MapView(this)
    setContentView(mapView)
    mapView.mapboxMap
      .apply {
        loadStyle(
          styleExtension = style {
            +rasterSource(RASTER_SOURCE_ID) {
              url("mapbox://mapbox.terrain-rgb")
              tileSize(256)
            }

            +backgroundLayer(BACKGROUND_LAYER_ID) {
              backgroundColor(Expression.rgb(4.0, 7.0, 14.0))
            }
            +rasterLayer(RASTER_LAYER_ID, RASTER_SOURCE_ID) {
              rasterColor(
                interpolate {
                  linear()
                  rasterValue()
                  stop {
                    literal(35.392)
                    rgb(48.0, 167.0, 228.0)
                  }
                  stop {
                    literal(44.24)
                    rgb(57.0, 143.0, 83.0)
                  }
                  stop {
                    literal(274.288)
                    rgb(116.0, 166.0, 129.0)
                  }
                  stop {
                    literal(486.64)
                    rgb(178.0, 205.0, 174.0)
                  }
                  stop {
                    literal(672.448)
                    rgb(188.0, 195.0, 169.0)
                  }
                  stop {
                    literal(955.584)
                    rgb(221.0, 207.0, 153.0)
                  }
                  stop {
                    literal(1353.744)
                    rgb(211.0, 174.0, 114.0)
                  }
                  stop {
                    literal(1813.84)
                    rgb(207.0, 155.0, 103.0)
                  }
                  stop {
                    literal(2450.896)
                    rgb(179.0, 120.0, 85.0)
                  }
                  stop {
                    literal(3318)
                    rgb(227.0, 210.0, 197.0)
                  }
                  stop {
                    literal(5839.68)
                    rgb(255.0, 255.0, 255.0)
                  }
                }
              )
              rasterColorMix(
                listOf(
                  1667721.6,
                  6553.6,
                  25.6,
                  -10000.0
                )
              )
              rasterColorRange(listOf(0.0, 8848.0))
            }
          }
        )
      }
  }

  companion object {
    private const val RASTER_SOURCE_ID = "raster-source-id"
    private const val BACKGROUND_LAYER_ID = "background-layer-id"
    private const val RASTER_LAYER_ID = "raster-layer-id"
  }
}
```