GeoTIFF Layer Leaflet Plugin
This plugin takes in pixel data or raster geoTiffs and generates an image layer
Dependencies:
- Leaflet >= 1.0.3
- geotiff.js
- plotty.js
Demo
Install the http-server package from npm
Install the http-server globally on your machine using the node package manager (npm) command line tool, this will allow you to run a web server from anywhere on your computer.
Open a command prompt / command line window and enter the following:
npm install -g http-server
Once http-server is installed navigate to the project folder and run the following command:
npm start
This will start a simple http server on http://127.0.0.1:8080
Importing
Using script tags
<!-- Load any renderer you need -->
In Angular 5
npm install url.git
should install leaflet, plotty, and geotiff, along with the javascript files needed.
;;;;;;
Pixel Data Binary
const cloudmask = './assets/data/test_wind_and_clouds/cloud_mask_2017036_2245.tif' band: 0 name: 'Cloud Mask' opacity: 1 renderer: colorScale: 'greys' ;
Pixel Data Color
const windspeed = './assets/data/test_wind_and_clouds/wind_speed_20170205_2000.tif' band: 0 name: 'Wind speed' opacity: 1 renderer: colorScale: 'rdbu' clampLow: false clampHigh: true displayMin: 50 displayMax: 57 ;
Arrows, Directional (Vector)
let windDirection = './examples/data/test_wind_and_clouds/wind_direction_20170205_0200.tif' band: 0 name: 'Wind speed' renderer: options= arrowSize: 20 ;
Options
band
: sets the rastor band to read (typically 0 or 1)bounds
: optional, array of the bounds if ommited will be read from the fileimage
: optional, set image to be read from tiff (if multiple images in tiff)clip
: optional set a clipping polygon in Leaflet.LatLondisplayMin
anddisplayMax
: set the min and max for the color scalesname
: name of the layercolorScale
: uses plotty for colors (see below)opacity
: percent in decimal form of alpha of layer (1 being opaque)vector
: boolean, true if you want to draw or have directional dataarrowSize
: int, sets the scale for arrow size, smaller means more arrows shownclampLow
andclampHigh
: booleans, optional, default = true. If true values outside displayMin to displayMax will be rendered as if they were valid values.
Color Scales
There is a list of predefined colorscales:
|
Note: Added 'whbl' color (not pictured above)
It is also possible to define your own colorscale using the addColorScale
function.
plotty;// ( identifier , color_steps, , percentage_steps)
Create a Legend
Using the options set in the new geotiff-leaflet object to make a legend!
const color = windspeedoptionsrenderer;const legend = L;legend { const div = LDomUtil; divinnerHTML += '<h5>'+windspeedoptionsname+'</h5>'; // loop through our density intervals and generate a label with a colored square for each interval for let i = 0; i < colorcolorslength; i+=1 divinnerHTML += '<i style="background:' + colorcolorsi + '"></i>'; ifi === 0 divinnerHTML += windspeedoptionsrendereroptionsdisplayMin; ifi === colorcolorslength-1 divinnerHTML += windspeedoptionsrendereroptionsdisplayMax; divinnerHTML += ' <br>'; return div;};legend{ let div = LDomUtil; return ;};legend;