npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

leaflet.idw

v0.0.1

Published

An Inverse Distance Weighting layer for leaflet; based on leaflet.heat

Readme

Leaflet.idw

A small Leaflet plugin to generate an IDW interpolated map

A tiny, simple and fast Leaflet inverse distance weighting plugin. Largely based on the Leaflet.heat plugin by Vladimir Agafonkin.

Leaflet.idw implements a simple inverse distance weighting algorithm). Every cell is calculated with the center of the cell (h/2,w/2) as the anchor from which the distance to the points is calculated.

Demos

Examples

CellSize: 1 Image of CellSize 1

CellSize: 5 Image of CellSize 1

CellSize: 10 Image of CellSize 1

Basic Usage

var idw = L.idwLayer([
    [50.5, 30.5, 0.2], // lat, lng, intensity
    [50.6, 30.4, 0.5],
    ...
], {opacity: 0.3, cellSize: 10, exp: 2, max: 1200}).addTo(map);

To include the plugin, just use leaflet-idw.js from the src folder:

<script src="leaflet-idw.js"></script>

Options

Constructs an IDW layer given an array of points and an object with the following options:

opacity - the opacity of the IDW layer
max - maximum point values, 1.0 by default
cellSize - height and width of each cell, 25 by default
exp - exponent used for weighting, 1 by default
gradient - color gradient config, e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}

Each point in the input array can be either an array like [50.5, 30.5, 0.5], or a Leaflet LatLng object.

Third argument in each LatLng point represents point value. Unless max option is specified, values should range between 0.0 and 1.0.

Performance

Performance is linked to number of points and cell size:

///////////////////////////////////////////////////////////

CellSize: 10px // ~100 Points // 14040 Cells

Draw directly with color:
process: timer started
process: 242.58ms 
draw 14040: timer started 
draw 14040: 24.27ms

Draw greyscale first:
process: timer started 
process: 244.68ms 
draw 14040: timer started 
draw 14040: 40.71ms


///////////////////////////////////////////////////////////

CellSize: 5px // ~100 Points // 56889 Cells

Draw directly with color:
process: timer started 
process: 1078.15ms 
draw 56889: timer started 
draw 56889: 80.17ms

Draw greyscale first:
process: timer started 
process: 1068.22ms 
draw 56889: timer started 1
draw 56889: 98.03ms

///////////////////////////////////////////////////////////

CellSize: 2px // ~100 Points // 349569 Cells

Draw directly with color:
process: timer started 
process: 8813.94ms 
draw 349569: timer started 
draw 349569: 787.89ms

Draw greyscale first:
process: timer started 
process: 8775.47ms 
draw 349569: timer started 
draw 349569: 493.78ms

ToDo

  • [ ] Delete unneeded parts of the code
  • [x] Rewrite code so that no greyscale image is generated first. Directly generate and color the cells
    • Performance tested
  • [x] Fix CellSize option: Now CellSize option X 2 = Cell width and height in pixels. (CellSize : 1 = 2x2 pixel cell)
  • [ ] Introduce a loading icon
  • [ ] Add the option for a bounding box
  • [ ] Cluster points to increase performance
    • If points in cell then take average for cell
  • [ ] Define bounding box for which points are used for each cell to increase performance
  • [ ] Introduce option to do IDW in map units and not in viewport?
  • [ ] Calculate one map tile after the other to minimise risk of browser freeze?
  • [ ] Split pipeline into processing and displaying? Save Grid after processing?

Changelog

0.0.2 — May 22, 2016

* Fixed cell size issue (now option is in pixels).
* Created script to generate IDW without greyscale step. See Performance section

0.0.1 — May 20, 2016

Initial release.