Skip to content

Coordinate data

The engine starts with no coordinate reference systems. It learns them from two kinds of files.

A registry file holds every system, datum and operation of one authority, such as EPSG. The npm package and the Python geodata extra include every registry file: epsg.bin, ogc.bin, esri.bin, iau_2015.bin for the Moon, Mars and other bodies, ignf.bin and nkg.bin. They also include the EGM96 geoid, which turns ellipsoid heights into heights above sea level.

A grid is a PROJ-data GeoTIFF file that some conversions read, such as uk_os_OSTN15_NTv2_OSGBtoETRS.tif for British National Grid. Grids are large, so the packages include none. A conversion that needs a missing grid fails with an error that names it, and geodata.gridsNeeded(source, target) lists the grids a conversion needs.

Install the packaged files

With no configuration, the loader sends every file the package includes, after it checks each file’s SHA-256:

import init, { geodata } from "@fslabs/spatialengine";

await init();
await geodata.install();
import spatialengine
import spatialengine_geodata

async with spatialengine.AsyncClient("localhost:50051") as client:
    await spatialengine_geodata.install(client)

Fetch grids

Both packages install a spatialengine-geodata command. grids downloads each grid you name from PROJ’s content delivery network, cdn.proj.org, checks it against the SHA-256 PROJ-data publishes, and writes it with a manifest.json into the folder you name. copy writes the packaged registry files and geoid into the same folder:

npx spatialengine-geodata grids uk_os_OSTN15_NTv2_OSGBtoETRS.tif --out geodata
npx spatialengine-geodata copy --out geodata

With the Python package, run the same commands without npx.

A browser cannot download grids from cdn.proj.org directly, because that server does not allow requests from other sites. A web app needs the grids on its own server.

Host the files on your own server

Serve the folder the command wrote, and point the loader at its URL. The loader reads manifest.json there, fetches each file by name, refuses a file whose SHA-256 does not match, and installs the rest:

await init({ geodataBaseUrl: "https://data.example.com/geodata/" });
await geodata.install();
await spatialengine_geodata.install(client, base_url="https://data.example.com/geodata/")

The Python base_url can also be a local directory. In JavaScript, geodata.from(baseUrl) returns a second loader for files you host apart from the others.