Skip to content

shapefile-wasmESRI Shapefiles, in the browser

Read and write shapefiles from GeoJSON — no server round-trip, no GDAL. A Rust core compiled to WebAssembly, with a small typed API in front of it.

Try it ​

ts
import { writeShapefileZip, readShapefileZip } from '@crmackey/shapefile-wasm';

const zip = await writeShapefileZip(
  {
    type: 'FeatureCollection',
    features: [
      {
        type: 'Feature',
        geometry: { type: 'Point', coordinates: [-93.265, 44.9778] },
        properties: { name: 'Minneapolis', pop: 429954 },
      },
    ],
  },
  { fileName: 'cities', epsg: 26915 },
);

const [layer] = await readShapefileZip(zip);
layer.geojson.features[0].properties.name; // "Minneapolis"

Why this exists ​

A shapefile is not one file. It is a .shp of geometry, a .shx index, a .dbf attribute table in a 1980s database format, and a .prj of projection text — all of which have to agree with each other. Getting that wrong produces files that open fine in one GIS and misbehave in another, usually without saying so.

This package leans on two well-tested Rust crates, shapefile and dbase, and handles the parts that are easy to get subtly wrong. Read more →

Released under the MIT License.