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

transformation-models

v2.0.0

Published

2D Affine, Helmert, Polynomial and TPS transformations for use in geodesy

Readme

Transformation Models

transformation-models provides 2D coordinate transformations for geodetic and mapping workflows.

Currently supported:

  • Affine
  • Helmert
  • Polynomial
  • TPS (Thin Plate Spline)

Install

Install with NPM:

npm install transformation-models

Or with Yarn:

yarn add transformation-models

Then import the methods you need:

import { Affine, Helmert, Polynomial, TPS } from 'transformation-models';

Common Usage

All transformation classes share the same basic API:

const transformation = new Affine(sourcePoints, targetPoints);

transformation.forward([4734064.359, 8615839.411]);
transformation.inverse([4732974.629, 492880.087]);
  • sourcePoints and targetPoints are arrays of 2D coordinates in the form [Northing, Easting]
  • forward(point) transforms from source to target
  • inverse(point) transforms from target to source

Transformation Types

Affine

An affine transformation models translation, rotation, scale, and shear. It preserves straight lines and collinearity.

Requires at least 3 control points.

import { Affine } from 'transformation-models';

const affine = new Affine(sourcePoints, targetPoints);

const result = affine.forward([4734064.359, 8615839.411]);
// [4732974.629, 492880.087]

Affine also supports exporting parameters as a world file:

const worldFile = affine.toWorldFile();

Helmert

A 2D Helmert transformation is a 4-parameter similarity transform. It models translation, uniform scale, and rotation, while preserving shape locally better than a general affine transform.

Requires at least 2 control points.

import { Helmert } from 'transformation-models';

const helmert = new Helmert(sourcePoints, targetPoints);

const result = helmert.forward([4734064.359, 8615839.411]);

Available fitted parameters include:

  • tx
  • ty
  • scale
  • rotation

Polynomial

A polynomial transformation fits a global polynomial surface between the control point sets. Higher orders can model broader non-linear distortions better than affine or Helmert transforms.

import { Polynomial } from 'transformation-models';

const polynomial = new Polynomial(sourcePoints, targetPoints, 2);

const result = polynomial.forward([4734064.359, 8615839.411]);

Notes:

  • order 1 behaves like a first-order polynomial transform and is equivalent to affine
  • order 2 and above can model non-linear distortion
  • minimum number of control points is (order + 1) * (order + 2) / 2
  • forward and inverse parameters are fitted separately from the control points

TPS

Thin Plate Spline (TPS) can model local deformations very well, but it does not preserve collinearity.

import { TPS } from 'transformation-models';

const tps = new TPS(sourcePoints, targetPoints);

const result = tps.forward([4734064.359, 8615839.411]);

TPS is usually a good fit when local warping is more important than preserving the geometric properties of a global linear model.

Example Control Points

const sourcePoints = [
  [4734563.812, 8602649.049],
  [4725349.627, 8610759.665],
  [4723443.326, 8616104.954],
  [4721845.431, 8622312.598],
  [4720159.801, 8603248.973],
  [4718040.498, 8608875.072],
  [4716553.179, 8620405.969],
  [4724628.766, 8631596.47],
  [4724538.865, 8629857.48],
  [4751688.217, 8617662.209],
  [4746994.861, 8621675.591],
  [4746480.919, 8608375.672],
  [4741551.591, 8615165.917],
  [4734308.135, 8616623.423],
  [4744231.665, 8630246.732],
  [4736133.859, 8630921.615],
  [4732346.726, 8627234.144]
];

const targetPoints = [
  [4733708.335, 479703.427],
  [4724353.409, 487647.473],
  [4722352.973, 492956.916],
  [4720645.585, 499133.77],
  [4719298.709, 480047.397],
  [4717080.395, 485633.91],
  [4715389.251, 497134.073],
  [4723263.059, 508463.146],
  [4723204.053, 506723.307],
  [4750559.251, 495015.878],
  [4745796.219, 498944.058],
  [4745519.337, 485640.022],
  [4740470.969, 492340.007],
  [4733204.376, 493668.131],
  [4742881.509, 507462.453],
  [4734775.168, 507992.948],
  [4731055.189, 504239.725]
];

License

transformation-models is licensed under the MIT License.