toGeoJSON
Converts the geometry to a GeoJSON Feature
object or a GeoJSON
FeatureCollection
object.
This function has 2 overloads, when called with:
- a single geometry object it returns a GeoJSON
Feature
object, - an array of geometry objects it returns a GeoJSON
FeatureCollection
object.
Converting multiple geometries into a single FeatureCollection
is faster
than converting each geometry into Feature
individually because it
processes the data in bulk.
Type Parameters
P
- The type of geometry/feature properties
Parameters
Name | Type | Description |
---|---|---|
geometryies | Geometry<P> | Geometry<P>[] | The geometry object or the array of geometry objects to be converted into a GeoJSON object |
Returns
GeoJSON_Feature<GeoJSON_Geometry, P> | GeoJSON_FeatureCollection<GeoJSON_Geometry, P>
GeoJSON Feature
or GeoJSON FeatureCollection
object
Throws
GEOSError
when called with an unsupported geometry type (not GeoJSON)
See also
GeometryRef#toJSON
converts geometry to a GeoJSONFeature
object