@developmentseed/epsg
The full EPSG projection database, compressed to 309kb for the web.
Some existing EPSG amalgamations exist, but all are uncompressed, incomplete, outdated, and/or not reproducible 1 2 3 4. This package uses the DecompressionStream API, now widely available in browsers, to bundle a gzip-compressed text file of WKT definitions for all 7352 defined EPSG projection codes.
Usage
Currently, the only package entrypoint is @developmentseed/epsg/all, which loads a Map<number, string>, with all EPSG definitions in OGC WKT2 format.
import loadEPSG from "@developmentseed/epsg/all";
import proj4 from "proj4";
// Load the EPSG database
const epsg = await loadEPSG();
// Access WKT strings by EPSG code.
const wkt4326 = epsg.get(4326);
const wkt3857 = epsg.get(3857);
// Then use proj4.js as normal
const converter = proj4(wkt4326, wkt3857);
const inputPoint = [1, 52];
const outputPoint = converter.forward(inputPoint);
Generate new EPSG definitions
First, download the latest EPSG definitions in WKT format. Go to epsg.org/download-dataset.html, create an account or log in, then download the WKT File version.
Then, from this directory, run
python scripts/generate.py
Then the file src/all.csv.gz will be updated with the latest EPSG definitions.
Publishing
The build script in package.json will automatically include all.csv.gz in the published NPM package.
If you get an error like
cp: dist/all.csv.gz: No such file or directory
You may need to delete an errant tsconfig.build.tsbuildinfo and try again. I'm not sure why.