• This repository has been archived on 08/Feb/2024
  • Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Load and style Raster files in Leaflet (geotiff & asciigrid)

IH.Leaflet.CanvasLayer.Field

A plugin for LeafletJS that adds layers to visualize fields (aka Rasters) from ASCIIGrid or GeoTIFF files (EPSG:4326).

Warning! New url for npm install

npm install ih-leaflet-canvaslayer-field

Leaflet.CanvasLayer.Field EXAMPLES

Travis CI npm version

It includes:

  • L.CanvasLayer.ScalarField - a "typical" raster layer (from scalars such as DTM, temperature...) that can be rendered with different color scales and arrows.
  • L.CanvasLayer.VectorFieldAnim - an animated layer representing a vector field (wind, currents...), based on the excellent earth by Cameron Becarrio

This plugin extends L.CanvasLayer Leaflet Plugin by Stanislav Sumbera and uses geotiff.js by Fabian Schindler. For the 'arrow' renderer, it includes a modified portion of leaflet-geotiff by Stuart Matthews.

Demo

The figures below show the results for three basic layers, showing Currents in the Bay of Santander (Spain)

Example

Example

Example

The following animation shows the usage of the built-in Layers Player controller to display an hypothetical precipitation event in the North American Great Lakes region.

Example

If you want to have a quick testing environment, have a look at these snippets at codepen.io:

Instructions

Basic Usage

  1. Get the JavaScript file. You can grab a copy from ongoing work at leaflet.canvaslayer.field.js. If you prefer to work locally with npm, then go with npm install ih-leaflet-canvaslayer-field --save. Every version is automatically published to unpkg CDN (last version at: https://unpkg.com/leaflet-canvaslayer-field/dist/leaflet.canvaslayer.field.js)

  2. Include the JavaScript dependencies in your page:

    <!-- CDN references -->
    <script src="//npmcdn.com/[email protected]/dist/leaflet.js"></script>
    
    <script src="//d3js.org/d3.v4.min.js"></script>
    <script src="//npmcdn.com/[email protected]/dist/geotiff.js"></script> <!-- optional -->

    <!-- Plugin -->
    <script src="https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/dist/leaflet.canvaslayer.field.js"></script>
  1. Prepare a Raster File with your favourite GIS tool, using EPSG:4326 (ASCII Grid or GeoTIFF format)

  2. Create a ScalarField layer and add it to the map, using your raster files as source (e.g. this .asc)

d3.text("https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/data/Bay_Speed.asc", function (asc) {
    var s = L.ScalarField.fromASCIIGrid(asc);
    var layer = L.canvasLayer.scalarField(s).addTo(map);

    map.fitBounds(layer.getBounds());
});
  1. Or try the VectorFieldAnim layer, adding also a popup (previously you have to prepare 2 raster files, with 'u' and 'v' components in 'm/s'):
d3.text('https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/data/Bay_U.asc', function(u) {
    d3.text('https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/data/Bay_V.asc', function(v) {
        let vf = L.VectorField.fromASCIIGrids(u, v);
        let layer = L.canvasLayer.vectorFieldAnim(vf).addTo(map);
        map.fitBounds(layer.getBounds());

        layer.on('click', function(e) {
            if (e.value !== null) {
                let vector = e.value;
                let v = vector.magnitude().toFixed(2);
                let d = vector.directionTo().toFixed(0);
                let html = (`<span>${v} m/s to ${d}&deg</span>`);
                let popup = L.popup()
                    .setLatLng(e.latlng)
                    .setContent(html)
                    .openOn(map);
            }
        });
    });
});

Developers

  • This plugin works with Leaflet >=v1.0.0
  • node & npm are needed to build and test the plugin, and it uses webpack 2 as module bundler. To use it just:
npm install
npm run start
  • Navigate to docs/index.html for some examples.

License

Licensed under the GNU General Public License v3.0

This software currently depends a copy of:

At runtime it uses:

More Repositories

1

THREDDSExplorer

Access and visualization of Meteo-Oceanographic dynamic data with QGIS
Python
18
star
2

ihFOAM

ihFOAM solvers for OpenFOAM
C++
15
star
3

NEOPRENE

Neyman-Scott Process Rainfall Emulator library
Jupyter Notebook
13
star
4

ihFOAM.materials

Manual and tutorials
C++
6
star
5

ihFOAM.mangroves

C++
4
star
6

mdapy

Data clustering algorithms library
Python
3
star
7

ViteTemplate.App

Vite template for web apps
SCSS
2
star
8

SIMPCCe

Librería para simular pronósticos de Cambio Climático en embalses
Jupyter Notebook
2
star
9

Sodin.Monitor

Operational system for detection and analysis of flooding events.
Python
1
star
10

datahub.client

datahub.client is a python library to make it easy to query datahub and obtain data stored in thredds.
Python
1
star
11

Sodin.Web

Web viewer #SodinProject
JavaScript
1
star
12

Pdf.Microservice

Generación de PDF con FastApi
HTML
1
star
13

pyteseo

Python package developed to simplify and facilitate the setup and processing of TESEO simulations (TESEO is a lagrangian numerical model developed by IHCantabria)
Python
1
star
14

RiosConCiencia.App

App #RiosConCiencia project. PWA para toma de datos en campo en el marco del Proyecto Ríos
Vue
1
star
15

msp.tools

Tools for IH-MSP Platform (Marine Spatial Planning http://msp.ihcantabria.com/)
Python
1
star
16

esfg_download

Nos permite descargar masivamente mediante WGET los diferentes ficheros netcdf que contienen los servidores de ESGF sobre cambio climático
Jupyter Notebook
1
star
17

template.net8.api

Use this template to easily implement asp net rest api.
C#
1
star
18

Documento_IA

Aplicación de técnicas de Inteligencia Artificial al sector de producción de energías renovables
TeX
1
star