Display GeoTIFFs and soon other types of raster on your Leaflet Map

Usage no npm install needed!

<script type="module">
  import georasterLayerForLeaflet from '';



Display GeoTIFFs and soon other types of rasters on your Leaflet Map


npm install georaster-layer-for-leaflet

GeoRaster Prerequisite

GeoRasterLayer requires that input be first converted into GeoRaster format. You can install GeoRaster with the following command:

npm install georaster

Load Package via Script Tag

<script src="">


new GeoRasterLayer({ georaster }).addTo(map);



  • Support for nearly all projections, thanks to proj4-fully-loaded and
  • Super faster rendering thanks to a simple nearest neighbor interpolation
  • Use of web workers means seamless integration that doesn't block main thread
  • Loads large geotiffs greater than a hundred megabytes
  • Supports custom rendering including custom colors, directional arrows, and context drawing
  • Doesn't depend on WebGL

The GeoRasterLayer Class

A custom class for rendering GeoTIFF's (including COG's) on a leaflet map. The layer extends L.GridLayer, see the docs for inherited options and methods.

Usage Example

Source Code:

var parse_georaster = require("georaster");

var GeoRasterLayer = require("georaster-layer-for-leaflet");

// initalize leaflet map
var map ='map').setView([0, 0], 5);

// add OpenStreetMap basemap
L.tileLayer('http://{s}{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="">OpenStreetMap</a> contributors'

var url_to_geotiff_file = "example_4326.tif";

  .then(response => response.arrayBuffer())
  .then(arrayBuffer => {
    parse_georaster(arrayBuffer).then(georaster => {
      console.log("georaster:", georaster);

          GeoRasterLayer is an extension of GridLayer,
          which means can use GridLayer options like opacity.

          Just make sure to include the georaster option!

          Optionally set the pixelValuesToColorFn function option to customize
          how values for a pixel are translated to a color.

      var layer = new GeoRasterLayer({
          georaster: georaster,
          opacity: 0.7,
          pixelValuesToColorFn: values => values[0] === 42 ? '#ffffff' : '#000000',
          resolution: 64 // optional parameter for adjusting display resolution




Method Returns Description
updateColors(pixelValuesToColorFn, options) this Causes the tiles to redraw without clearing them first. It uses the updated pixelValuesToColorFn function. You can set a debugLevel specific to this function by passing in an options object with a debugLevel property. For example, you can turn on the console debugs for this method by setting debugLevel = 1 in the options (even if you created the layer with debugLevel = 0).

Advanced Capabilities

Please read about our advanced capabilities including custom context drawing functions and displaying directional arrows in

More Questions

Check out our Frequently Asked Questions


Contact the package author, Daniel J. Dufour, at