Skip to main content

fromGeoJSON

Creates a Geometry from GeoJSON representation.

This function has 2 overloads, when called with:

  • GeoJSON Geometry or GeoJSON Feature it returns a single geometry,
  • GeoJSON FeatureCollection it returns an array of geometries.

GeoJSON Feature properties are saved in the props field of the created geometry object.

Loading multiple geometries from a single FeatureCollection is faster than loading each geometry individually because it processes the data in bulk.

Type Parameters

  • P - The type of geometry/feature properties

Parameters

NameTypeDescription
geojsonGeoJSON_Geometry | GeoJSON_Feature<GeoJSON_Geometry, P> | GeoJSON_FeatureCollection<GeoJSON_Geometry, P>GeoJSON Geometry, Feature or FeatureCollection

Returns

Geometry<P> | Geometry<P>[]

A new geometry object or an array of new geometry objects

Throws

See also

  • point shortcut to create Point geometry
  • lineString shortcut to create LineString geometry
  • polygon shortcut to create Polygon geometry
  • multiPoint shortcut to create MultiPoint geometry
  • multiLineString shortcut to create MultiLineString geometry
  • multiPolygon shortcut to create MultiPolygon geometry

Examples