Skip to content

Function: writeShapefileZip() ​

ts
function writeShapefileZip(geojson, options?): Promise<Uint8Array<ArrayBufferLike>>;

Defined in: write.ts:136

Converts GeoJSON into a zipped shapefile bundle.

The archive holds .shp, .shx, .dbf and .cpg, plus a .prj when a projection was given — the set of files a GIS expects to find together.

Accepts the same input as writeShapefile and applies the same rules.

Parameters ​

ParameterTypeDescription
geojsonstring | GeoJsonInputThe GeoJSON to convert. See writeShapefile.
optionsZipOptionsEverything writeShapefile takes, plus fileName for the base name used inside the archive and level for the DEFLATE level.

Returns ​

Promise<Uint8Array<ArrayBufferLike>>

The zip archive as bytes — write it to disk, upload it, or pass it to downloadShapefileZip from @crmackey/shapefile-wasm/browser.

Throws ​

Everything writeShapefile throws.

Example ​

ts
const zip = await writeShapefileZip(featureCollection, {
  fileName: 'stations',
  epsg: 26915,
});
await writeFile('stations.zip', zip);

Released under the MIT License.