Skip to main content

write_shapefile

Function write_shapefile 

Source
pub fn write_shapefile(
    geojson: JsValue,
    options: JsValue,
) -> Result<ShapefileParts, JsValue>
Expand description

Builds a shapefile from a GeoJSON value passed straight across the wasm boundary.

A shapefile holds exactly one geometry type, so mixed input is rejected — except Point and MultiPoint, which are promoted to a single Multipoint file. Dimensionality follows the coordinates unless options.dimensions overrides it, and the .dbf schema is inferred from every feature’s properties.

§Arguments

  • geojson - A FeatureCollection, a lone Feature, a bare geometry, or an array of any of those.
  • options - An Options object, or null/undefined for the defaults.

§Errors

Returns a JavaScript Error when the input is not valid GeoJSON, mixes incompatible geometry types, holds no writable features, contains a malformed coordinate or a degenerate ring, or uses GeometryCollection.