Skip to content

Function: downloadShapefileZip() ​

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

Defined in: browser.ts:96

Converts GeoJSON to a zipped shapefile and saves it to the user's downloads.

A convenience wrapper over writeShapefileZip and triggerDownload. The bytes come back too, so the same archive can be uploaded or cached without building it a second time.

Parameters ​

ParameterTypeDescription
geojsonstring | GeoJsonInputThe GeoJSON to convert. See writeShapefile.
optionsZipOptionsEverything writeShapefileZip takes. fileName names both the downloaded archive and the files inside it.

Returns ​

Promise<Uint8Array<ArrayBufferLike>>

The zip archive as bytes.

Throws ​

Outside a browser, or for any reason writeShapefileZip throws — mixed geometry types, an unresolvable EPSG code, and so on.

Example ​

ts
button.addEventListener('click', async () => {
  await downloadShapefileZip(featureCollection, {
    fileName: 'survey-points',
    epsg: 26915,
  });
});

Released under the MIT License.