stuartmatthews / leaflet-geotiff

Leaflet plugin for displaying geoTIFF raster data
MIT License
174 stars 76 forks source link

leaflet-geotiff

A LeafletJS plugin for displaying geoTIFF raster data. Data can drawn as colored rasters or directon arrows. The layer can be clipped using a polygon.

DEMO

Sample

Instructions

1. Include the JavaScript file and dependencies

    <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
    <script src="https://unpkg.com/geotiff@0.4.1/dist/main.js"></script>
    <script src="https://unpkg.com/plotty@0.2.0/src/plotty.js"></script>
    <script src="https://github.com/stuartmatthews/leaflet-geotiff/raw/master/leaflet-geotiff.js"></script>
    <!-- Load any renderer you need -->
    <script src="https://github.com/stuartmatthews/leaflet-geotiff/raw/master/leaflet-geotiff-plotty.js"></script>
    <script src="https://github.com/stuartmatthews/leaflet-geotiff/raw/master/leaflet-geotiff-vector.js"></script>

2. Add a geoTIFF layer

// Create map
var layer = L.leafletGeotiff(url, options).addTo(map);

Parameters:

Renderer

Raster data rendered using Plotty: L.LeafletGeotiff.plotty(options) Options:

New color scales can be created using plotty's addColorScale method.

Vector data rendered as arrows: L.LeafletGeotiff.vectorArrows(options) Options:

Advanced usage options

  1. Data values can be extracted using the getValueAtLatLng(lat,lng) method.
  2. Custom renderer can be implemented by extending L.LeafletGeotiffRenderer.

Dependencies