Skip to main content

Function: topojsonToGeojson()

topojsonToGeojson(topology, objectName?): GeoFeatureCollection

Defined in: src/mobjects/geo/topojson.ts:144

Convert a TopoJSON topology into a GeoFeatureCollection.

One object of the topology is decoded. A GeometryCollection becomes one feature per contained geometry; any other geometry becomes a single feature. Arcs are delta-decoded and de-quantized with the topology transform, shared arcs are stitched, and a negative arc index selects that arc reversed.

Parameters​

topology​

Topology

The TopoJSON topology object.

objectName?​

string

Which entry of topology.objects to decode. Defaults to the first entry.

Returns​

GeoFeatureCollection

A GeoJSON feature collection with Point, LineString and Polygon geometries (and their Multi variants).

Throws​

If the topology is malformed, an arc index is out of range, or the requested object is missing.