georaster-layer-for-leaflet

Advanced Features

Custom Draw Function

You can directly edit the canvas that is being rendered by passing in a customDrawFunction. The custom draw function takes in an object with the following keys:

Here’s a rough example implementing drawing of wind direction arrows: https://geotiff.github.io/georaster-layer-for-leaflet-example/examples/wind-direction-arrows.html and the source code for it.

Setting the Log Level

You can turn on extra console logging for debugging purposes by setting the debugLevel to 1 or greater.

new GeoRasterLayer({
  georaster,
  debugLevel: 1
})

Reducing your Build Size

The default builds of GeoRasterLayer include support for nearly all projections. Of course, this increases the total build size of the library by a lot, specifically from about 54kb to 311kb. If you don’t want this built-in support, you can use the lite version of the library, which is found at ./dist/georaster-layer-for-leaflet.lite.min.js. This means you’ll want to do const GeoRasterLayer = require('georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.lite.min.js') or import GeoRasterLayer from 'georaster-layer-for-leaflet/dist/georaster-layer-for-leaflet.lite.min.js when loading the library.

Masking

You can hide all the pixels either inside or outside a given mask geometry. You can provide a JSON object as a mask geometry or a URL to a GeoJSON.

// only display what is inside the borders of the USA
new GeoRasterLayer({
  georaster,
  mask: "./usa.geojson",
  mask_strategy: "inside"
});

// hide all the land masses
new GeoRasterLayer({
  georaster,
  mask: { type: "FeatureCollection", features: [ /* .. */] }, // a GeoJSON for the world's oceans
  mask_strategy: "outside"
});

Turbo Mode

You can enable turbo mode, which will in some cases lead to better performance. However, it is experimental, so should be tested first on your data before using in production. Internally, it uses proj-turbo.