fromGeoJSON
Creates a Geometry
from GeoJSON representation.
This function has 2 overloads, when called with:
- GeoJSON
Geometry
or GeoJSONFeature
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
Name | Type | Description |
---|---|---|
geojson | GeoJSON_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
InvalidGeoJSONError
on GeoJSON feature without geometryInvalidGeoJSONError
on invalid GeoJSON geometry
See also
point
shortcut to createPoint
geometrylineString
shortcut to createLineString
geometrypolygon
shortcut to createPolygon
geometrymultiPoint
shortcut to createMultiPoint
geometrymultiLineString
shortcut to createMultiLineString
geometrymultiPolygon
shortcut to createMultiPolygon
geometry