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

geo-morpher

v0.1.5

Published

GeoJSON morphing utilities with MapLibre-first adapter and Leaflet compatibility

Downloads

871

Readme

geo-morpher

npm version License: MIT

GeoJSON morphing utilities for animating between regular geography and cartograms, with first-class MapLibre GL JS support. Smoothly interpolate between any two aligned GeoJSON geometries and overlay multivariate glyphs that stay in sync.

[!TIP] To quickly create a grid cartogram, check out gridmapper (https://danylaksono.is-a.dev/gridmapper/).

Features

  • MapLibre-first: High-performance adapter for modern vector maps.
  • Smooth Morphing: Seamlessly interpolate between any two aligned GeoJSON geometries (using flubber).
  • Multivariate Glyphs: Position-synced DOM overlays for charts, icons, and sparklines.
  • Basemap Effects: Synchronized fading and styling of basemaps during transitions.
  • Projection Agnostic: Automatic support for WGS84, OSGB, and custom projections.

Installation

npm install geo-morpher

Quick Start (MapLibre)

import maplibregl from "maplibre-gl";
import { GeoMorpher, createMapLibreMorphLayers } from "geo-morpher";

// 1. Prepare data (regular vs cartogram geography)
const morpher = new GeoMorpher({
  regularGeoJSON: await (await fetch('regular_lsoa.json')).json(),
  cartogramGeoJSON: await (await fetch('cartogram_lsoa.json')).json(),
});
await morpher.prepare();

// 2. Initialize MapLibre
const map = new maplibregl.Map({ ... });

map.on('load', async () => {
  // 3. Create morphing layers
  const morph = await createMapLibreMorphLayers({
    morpher,
    map,
    interpolatedStyle: {
      paint: { "fill-color": "#22c55e", "fill-opacity": 0.4 }
    }
  });

  // 4. Drive the morph (0 = regular, 1 = cartogram)
  morph.updateMorphFactor(0.5);
});

Multivariate Glyphs

Overlay custom visualizations (SVG, Canvas, or HTML) that stay synced with the morphing polygons.

import { createMapLibreGlyphLayer } from "geo-morpher";

const glyphLayer = await createMapLibreGlyphLayer({
  morpher,
  map,
  drawGlyph: ({ data, feature }) => ({
    html: `<div class="glyph">${feature.properties.value}</div>`,
    iconSize: [40, 40],
    iconAnchor: [20, 20]
  }),
  maplibreNamespace: maplibregl
});

// Update glyphs during morphing
glyphLayer.updateGlyphs({ morphFactor: 0.5 });

Basemap Effects

Automatically adjust basemap styles as you morph to focus attention on the data.

const morph = await createMapLibreMorphLayers({
  morpher,
  map,
  basemapEffect: {
    layers: ["osm-tiles"],
    properties: {
      "raster-opacity": [1, 0.25],
      "raster-saturation": [0, -1]
    }
  }
});

Core API

GeoMorpher

The core engine for geometry interpolation.

  • new GeoMorpher({ regularGeoJSON, cartogramGeoJSON, data, aggregations })
  • prepare(): Run initialization (projection, enrichment).
  • getInterpolatedFeatureCollection(factor): Get the geometry at a specific state.

Projections

Auto-detects WGS84 or OSGB. For UTM or others:

import { createProj4Projection } from "geo-morpher";
import proj4 from "proj4";

const projection = createProj4Projection("+proj=utm +zone=33 +datum=WGS84", proj4);
const morpher = new GeoMorpher({ ..., projection });

Examples

Run the local server to see demos:

npm run examples:browser
  • MapLibre Demo: Basic morphing and glyphs.
  • Indonesia: Large-scale, multipolygon geometry morphing.
  • Projections: Custom coordinate systems.

Legacy Support

Leaflet is still supported via createLeafletMorphLayers and createLeafletGlyphLayer. See API Reference for details.

Documentation

License

MIT © Dany Laksono