Skip to content

Function: writeLayers() ​

ts
function writeLayers(layers, options?): Promise<WrittenLayer[]>;

Defined in: layers.ts:153

Converts several GeoJSON inputs, without packing them.

Use this when you want the per-layer metadata — feature counts, field renames, skipped features — and not just the bytes. Feed the result to zipLayers when you are ready to pack it.

Parameters ​

ParameterTypeDescription
layersreadonly LayerInput[]The layers to write.
optionsWriteLayersOptionsShared write options. layout, folder and level are ignored here; they matter only when packing.

Returns ​

Promise<WrittenLayer[]>

One entry per layer, in the order given.

Throws ​

If layers is empty, if two layers resolve to the same name, or if any layer fails to convert.

Example ​

Report on a batch before shipping it

ts
const written = await writeLayers(layers, { epsg: 26915 });

for (const layer of written) {
  console.log(layer.name, layer.parts.shapeType, layer.parts.featureCount);
  if (layer.parts.skippedCount) {
    console.warn(`${layer.name}: skipped ${layer.parts.skippedCount}`);
  }
}

const zip = zipLayers(written, { layout: 'folders' });

Released under the MIT License.