# @allmaps/analyze

> Allmaps Analysis Library

Latest version **1.0.0-beta.14** (published 2026-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @allmaps/analyze
pnpm add @allmaps/analyze
yarn add @allmaps/analyze
bun add @allmaps/analyze
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.0-beta.14 |
| Published | 2026-09-22 |
| First published | 2025-03-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 9 |
| Unpacked size | 57.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 153 |
| Author | Manuel Claeys Bouuaert |
| Maintainers | bertspaan |
| Keywords | allmaps, analyze, georeference, map |

## Links

- npm: https://www.npmjs.com/package/@allmaps/analyze
- Repository: https://github.com/allmaps/allmaps
- Homepage: https://allmaps.org
- Issues: https://github.com/allmaps/allmaps/issues
- npm.io page: https://npm.io/package/@allmaps/analyze

## Dependencies (9)

- [ml-matrix](https://npm.io/package/ml-matrix.md) ^6.12.0
- [ml-ransac](https://npm.io/package/ml-ransac.md) ^1.0.0
- [@allmaps/types](https://npm.io/package/@allmaps/types.md) ^1.0.0-beta.24
- [@allmaps/render](https://npm.io/package/@allmaps/render.md) ^1.0.0-beta.84
- [@allmaps/stdlib](https://npm.io/package/@allmaps/stdlib.md) ^1.0.0-beta.42
- [@allmaps/project](https://npm.io/package/@allmaps/project.md) ^1.0.0-beta.10
- [@allmaps/transform](https://npm.io/package/@allmaps/transform.md) ^1.0.0-beta.53
- [@allmaps/annotation](https://npm.io/package/@allmaps/annotation.md) ^1.0.0-beta.38
- [point-in-polygon-hao](https://npm.io/package/point-in-polygon-hao.md) ^1.2.4

## Recent versions

- 1.0.0-beta.14 (latest) — 2026-09-22
- 1.0.0-beta.4 (beta) — 2025-05-22
- 1.0.0-beta.13 — 2026-05-28
- 1.0.0-beta.12 — 2026-02-09
- 1.0.0-beta.11 — 2025-12-09
- 1.0.0-beta.10 — 2025-11-27
- 1.0.0-beta.9 — 2025-11-10
- 1.0.0-beta.8 — 2025-07-19
- 1.0.0-beta.7 — 2025-07-19
- 1.0.0-beta.6 — 2025-07-09
- 1.0.0-beta.5 — 2025-07-07
- 1.0.0-beta.3 — 2025-05-22
- 1.0.0-beta.2 — 2025-03-12

## README

# @allmaps/analyze

This packages serves to analyze the *geometric* qualities of georeferenced maps.

Examples:

*   Check if there are enough GCPs and they are linearly independent
*   Check if the mask doesn't self-intersect
*   Check if the map is not to strongly warped

## How it works

This packages analyzes maps and returns information, warning and error items:

*   **Info** are notable but not problematic informations on a warping.
*   **Warnings** are possibly problematic findings, but don't invalidate the map.
*   **Errors** are problematic findings that invalidate the map.

Analysis items like info, warnings and errors are objects with a unique code, a message and possible additional descriptive attributes. All supported analysis items are listed below.

An analyzer can also compute **Measures** like the RMSE of error-vectors and **Distortion** information like area scaling of a thin-plate spline transformation. They are equally described below.

While this packages serves to analyze the *geometric* qualities of maps. It does not check the *online availability* of the resource (image) of a map.

### Which maps can be analyzed?

This package can analyze ProtoGeoreferencedMaps, GeoreferencedMaps or WarpedMaps.

*   A **ProtoGeoreferencedMap** is a type used in this package to describe a basic version of a GeoreferencedMap containing only (but not guaranteed) GCPs and a mask. Information on the resource image or context, present in a GeoreferencedMap may be omitted here.
*   A **GeoreferencedMap** is Allmaps' internal map format describing parsed [Georeference Annotations](https://iiif.io/api/extension/georef/). The [@allmaps/annotation](../../packages/annotation/) package defines these schema's and provides functions to parse and generate them.
*   A **WarpedMap** is an object used in the [@allmaps/render](../../packages/render/) package and describe how a Georeferenced Map is warped by a transformer, e.g. during rendering. Hence, these objects contain a lot of information that can be used to infer the quality and accuracy of a map's warping.
    *   This packages also check if WarpedMap's can be triangulated. For context: a WebGL2Renderer renders a WebGL2WarpedMap, which is an extension a TriangulatedWarpedMap, which is an extension of a WarpedMap.

## Installation

This is an ESM-only module that works in browsers and Node.js.

Install with pnpm:

```sh
pnpm install @allmaps/analyze
```

## Usage

First, create an Analyzer instance from a ProtoGeoreferencedMap, GeoreferencedMap or WarpedMap.

```js
import { parseAnnotation } from '@allmaps/annotation'
import { Analyzer } from '@allmaps/analyze'

// Create an Analyzer for a Proto Georeferenced Map
const protoGeoreferencedMap = {
  "gcps": [
    { "resource": [336, 1742], "geo": [2.2860069, 48.860451] },
    { "resource": [294, 227], "geo": [2.2860069, 48.860451] }, // <- geo point repeated
    { "resource": [2252, 1108], "geo": [2.2945555, 48.8574745] },
    { "resource": [1892, 773], "geo": [2.2945164, 48.8590133] }
  ],
  "resourceMask": [
    [117, 120],
    [113, 1776],
    [4587, 1772],
    [4568, 101]
  ]
}
const analyzer = new Analyzer(protoGeoreferencedMap)

// Or create an Analyzer for a Georeferenced Map
const annotation = await fetch(annoationUrl).then((response) => response.json())
const georeferencedMaps = parseAnnotation(annotation)
const georeferencedMap = georeferencedMaps[0]
const analyzer = new Analyzer(georeferencedMap)

// Or create an Analyzer for a Warped Map
await renderer.addGeoreferenceAnnotation(annotation)
const warpedMap = renderer.warpedMapList.getWarpedMaps()[0]
const analyzer = new Analyzer(warpedMap)
```

Then analyze for info, warnings or errors, or compute measures or distortion.

```js
// Run an analysis to get all info, warnings and errors
const analysis = analyzer.analyze()
// analysis.warnings = {
//   {
//     mapId: 'https://annotations.allmaps.org/images/5748b8df80495d97',
//     code: 'gcpgeorepeatedpoint',
//     geoPoint: [ 2.2860069, 48.860451 ],
//     gcpIndex: 1,
//     message: 'GCP 1 with geo coordinates [2.2860069,48.860451] is repeated.'
//   },
//   ...
// }

// Or specifically get info, warnings and errors
const info = analyzer.getInfo()
const warnings = analyzer.getWarnings()
const errors = analyzer.getErrors()

// Or quickly check e.g. if there are any errors
const hasErrors = analyzer.hasErrors()

// Analyze measures and distortions
const measures = analyzer.getMeasures()
const distortions = analyzer.getDistortions()
```

## Info, Warnings, Errors

An analyzer can analyze the following info, warnings and errors:

| Type    | Code                                      | Topic                                                                                                                                                              | Included by default |
|---------|-------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------|
| Info    | `maskequalsfullmask`                      | The mask contains the full image.                                                                                                                                  | Yes                 |
| Info    | `gcpresourcepointismaskpoint`             | A GCP is a mask point.                                                                                                                                             | Yes                 |
| Warning | `maskmissing`                             | A mask is missing.                                                                                                                                                 | Yes                 |
| Warning | `gcpoutsidemask`                          | A GCP is outside the mask.                                                                                                                                         | Yes                 |
| Warning | `gcpoutlier`                              | A GCP is possibly an outlier. See [this notebook](https://observablehq.com/d/decede2fed6b58d3) for more details about the RANSAC approach used to detect outliers. | Yes                 |
| Warning | `maskpointoutsidefullmask`                | A mask point is outside the full mask.                                                                                                                             | Yes                 |
| Warning | `destinationrmsetoohigh`                  | The RMSE is higher then the set maximum times the map diameter.                                                                                                    | No                  |
| Warning | `destinationhelmertrmsetoohigh`           | The RMSE is higher then the set maximum times the map diameter for a helmert transformation.                                                                       | No                  |
| Warning | `polynomial1sheartoohigh`                 | The shear is higher then a set maximum for a polynomial transformation.                                                                                            | Yes                 |
| Warning | `destinationpolynomial1rmsetoohigh`       | The RMSE is higher then the set maximum times the map diameter for a polynomial transformation.                                                                    | Yes                 |
| Warning | `log2sigmadistortiontoohigh`              | The area distortion (`log2sigma`) is higher then the set maximum or lower then the set minimum.                                                                    | Yes                 |
| Warning | `twoomegadistortiontoohigh`               | The angular distortion (`twoOmega`) is higher then the set maximum.                                                                                                | Yes                 |
| Warning | `triangulationfoldsover`                  | The warped map folds over itself.                                                                                                                                  | No                  |
| Error   | `constructinggeoreferencedmapfailed`      | A georeferenced map could not be constructed.                                                                                                                      | Yes                 |
| Error   | `constructingtriangulatedwarpedmapfailed` | A triangulated warped map could not be constructed.                                                                                                                | Yes                 |
| Error   | `constructingwarpedmapfailed`             | A warped map could not be constructed.                                                                                                                             | Yes                 |
| Error   | `gcpsmissing`                             | GCPs are missing.                                                                                                                                                  | Yes                 |
| Error   | `gcpincompleteresource`                   | A GCP has incomplete source coordinates.                                                                                                                           | Yes                 |
| Error   | `gcpincompleteregeo`                      | A GCP has incomplete source coordinates.                                                                                                                           | Yes                 |
| Error   | `gcpsamountlessthen2`                     | There are less then 2 GCPs.                                                                                                                                        | No                  |
| Error   | `gcpsamountlessthen3`                     | There are less then 3 GCPs.                                                                                                                                        | Yes                 |
| Error   | `gcpresourcerepeatedpoint`                | GCP resource coordinates are repeated.                                                                                                                             | Yes                 |
| Error   | `gcpgeorepeatedpoint`                     | GCP geo coordinates are repeated.                                                                                                                                  | Yes                 |
| Error   | `gcpsresourcenotlinearlyindependent`      | GCP resource coordinates are not linearly independent.                                                                                                             | Yes                 |
| Error   | `gcpsgeonotlinearlyindependent`           | GCP geo coordinates are not linearly independent.                                                                                                                  | Yes                 |
| Error   | `masknotring`                             | The mask is not a valid ring (an array of points).                                                                                                                 | Yes                 |
| Error   | `maskrepeatedpoint`                       | Mask resource coordinates are repeated.                                                                                                                            | Yes                 |
| Error   | `maskselfintersection`                    | The mask self-intersects.                                                                                                                                          | Yes                 |

Note: computing the warnings can throw an error (e.g. if there are not enough GCPs). This error is caught and added to the errors when a full analysis is performed, but not when only the warnings are computed.

#### Options

An analysis accepts the following options:

| Option                            | Description                                                                                   | Default                                                 |
| :-------------------------------- | :-------------------------------------------------------------------------------------------- | :------------------------------------------------------ |
`codes` | Array of codes to analyze. | (see above) |
`maxRmseDiameterFraction` | Maximum allowed RMSE as a fraction of the map diameter' | `0.05` |
`maxShear` | Maximum allowed shear for a polynomial transformation' | `0.1` |
`maxLog2sigma` | Maximum allowed area scaling distortion (log2sigma)' | `1` |
`minLog2sigma` | Minimum allowed area scaling distortion (log2sigma)' | `-1` |
`maxTwoOmega` | Maximum allowed angular distortion (twoOmega)' | `0.5` |
`ransacThresholdFactor` | RANSAC scaling factor applied to the RANSAC inlier distance threshold when detecting outlier GCPs' | `0.1` |
`ransacStopProbability` | RANSAC stopping probability when detecting outlier GCPs' | `0.99` |
`ransacMaxNbIterations` | Maximum number of RANSAC iterations when detecting outlier GCPs' | `100` |

## Measures

An analyzer can also compute measures describing the warping with the current (or default) transformation type, and measures specifically describing warpings with Helmert and polynomial transformation types.

The method `analyze.getMeasures()` returns an object with the following measures:

*   About the current transformation type:
    *   `resourceMaskBboxDiameter`: The diameter of the bounding box of the resource mask.
    *   `geoMaskBboxDiameter`: The diameter of the bounding box of the geo mask.
    *   `projectedGeoMaskBboxDiameter`: The diameter of the bounding box of the projected geo mask.
    *   `destinationRmse`: The root-mean-square error of GCPs in projected geo coordinates.
    *   `destinationErrors`: for each GCP, the error in projected geo coordinates.
    *   `resourceErrors`: for each GCP, the error in projected geo coordinates, scaled to resource space.
    *   `resourceRelativeErrors`: for each GCP, the error in projected resource coordinates, relative to the diameter of the bounding box of the resource mask.
*   About the Helmert transformation type:
    *   `destinationHelmertRmse`: The root-mean-square error of GCPs in projected geo coordinates.
    *   `helmertMeasures`: The Helmert measures, including `translation`, `rotation` and `scale`. See [@allmaps/transform](../../packages/transform/).
*   About the polynomial transformation type:
    *   `destinationPolynomial1Rmse`: The root-mean-square error of GCPs in projected geo coordinates.
    *   `polynomial1Measures`: The polynomial measures, including `translation`, `rotation`, `scales` and `shears`. See [@allmaps/transform](../../packages/transform/).

## Distortions

An analyzer can also compute distortion describing the distortion caused by the warping with the current (or default) transformation type.

The method `analyze.getDistortions()` returns an object with the following measures:

*   About the current transformation type:
    *   `meanDistortions`: A Map with for each computed distortion measure, the mean distortion over all triangulation points.

## License

MIT

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [Analyzer](#analyzer)
    *   [Parameters](#parameters)
    *   [analyze](#analyze)
        *   [Parameters](#parameters-1)
    *   [getInfo](#getinfo)
        *   [Parameters](#parameters-2)
    *   [getWarnings](#getwarnings)
        *   [Parameters](#parameters-3)
    *   [getErrors](#geterrors)
        *   [Parameters](#parameters-4)
    *   [getMeasures](#getmeasures)
    *   [getDistortions](#getdistortions)

### Analyzer

Class for Analyzer.
This class describes how a georeferenced map is warped using a specific transformation.

#### Parameters

*   `map` &#x20;
*   `options` &#x20;

#### analyze

Analyzanalye

Applying extra caution: wrapping the getters in a try catch

##### Parameters

*   `partialOptions`  Analysis options

Returns **any** Analysis with info, warnings and errors

#### getInfo

Get analysis informations

##### Parameters

*   `partialOptions`  Analysis options

Returns **any** Analysis items with info

#### getWarnings

Get analysis warnings

##### Parameters

*   `partialOptions`  Analysis options

Returns **any** Analysis items with warning

#### getErrors

Get analysis errors

##### Parameters

*   `partialOptions`  Analysis options

Returns **any** Analysis items with errors

#### getMeasures

Get analysis measures

Returns **any** Analysis measures

#### getDistortions

Get distortions.

Returns **any** Analysis distortions

---
_Source: https://npm.io/package/@allmaps/analyze · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
