Skip to main content

Class: RasterReprojector

Defined in: delatin.ts:143

RasterReprojector performs a Delaunay triangulation-based reprojection of a raster image.

It takes as input a set of functions to associate pixel positions with coordinates in the input and output CRS, as well as the dimensions of the output image, and it produces a triangulated mesh that can be used to reproject the input raster onto the output raster with bounded error.

Constructors​

Constructor​

new RasterReprojector(reprojectors, width, height?, options?): RasterReprojector

Defined in: delatin.ts:208

Parameters​

reprojectors​

ReprojectionFns

width​

number

height?​

number = width

options?​
_errorSpace?​

"input" | "output"

Where each test point's error is measured.

  • "input" (default): in input pixels. The GPU's position for the test point is mapped back to the input space with the inverse functions, and the error is its distance from the test point. This is similar to gdalwarp's linear approximator.
  • "output": in output pixels. The error is the distance on the map between where the test point belongs and where the GPU draws it, then divided by one input pixel's size on the map at the center of the meshed area, or across it where the pixel at the center has no size. So the unit of maxError is still a number of pixels. The inverse functions are never called.

This option is experimental and may change or be removed.

initialTriangulation?​

InitialTriangulation

Returns​

RasterReprojector

Properties​

exactOutputPositions​

exactOutputPositions: number[]

Defined in: delatin.ts:163

XY Positions in output CRS, computed via exact forward reprojection.


height​

height: number

Defined in: delatin.ts:150

Height of the image in pixels


reprojectors​

reprojectors: ReprojectionFns

Defined in: delatin.ts:144


triangles​

triangles: number[]

Defined in: delatin.ts:168

triangle vertex indices


uvs​

uvs: number[]

Defined in: delatin.ts:158

UV vertex coordinates (x, y), i.e. [x0, y0, x1, y1, ...]

These coordinates are floats that range from [0, 1] in both X and Y.


width​

width: number

Defined in: delatin.ts:147

Width of the image in pixels

Methods​

getMaxError()​

getMaxError(): number

Defined in: delatin.ts:323

Returns​

number


refine()​

refine(): void

Defined in: delatin.ts:317

Returns​

void


run()​

run(maxError?, maxIterations?): void

Defined in: delatin.ts:294

Refine the mesh until its maximum error gets below the given one

Parameters​

maxError?​

number = DEFAULT_MAX_ERROR

The maximum error the mesh should achieve, in pixels: input pixels, or in output mode, output pixels (one input pixel's size on the map, normally at the center of the meshed area).

maxIterations?​

Optional safeguard to prevent infinite loops in case of non-convergence. If the mesh fails to converge within this number of iterations, a warning will be logged and the function will return early.

maxIterations?​

number = 10000

Returns​

void

[return description]