fromGeoJSON
Creates a Geometry from GeoJSON representation.
This function has 2 overloads, when called with:
- GeoJSON
Geometryor GeoJSONFeatureit returns a single geometry, - GeoJSON
FeatureCollectionit returns an array of geometries.
In addition to the 7 standard GeoJSON geometries, this reader also supports
JSON representation of other geometries supported by GEOS like
JSON_CircularString, JSON_CompoundCurve or JSON_CurvePolygon.
Reader expects that all positions in an input geometry have the same number of elements. The geometry coordinate dimension is determined from the first encountered position.
Type Parameters
P- The type of geometry/feature properties
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
geojson | GeoJSON_Geometry | GeoJSON_Feature<GeoJSON_Geometry, P> | GeoJSON_FeatureCollection<GeoJSON_Geometry, P> | JSON_Geometry | JSON_Feature<JSON_Geometry, P> | JSON_FeatureCollection<JSON_Geometry, P> | GeoJSON Geometry, Feature or FeatureCollection | |
options? | object | Optional GeoJSON input configuration | |
options.layout? | 'XY' | 'XYZ' | 'XYZM' | 'XYM' | 'XYZM' | Coordinate layout for interpreting GeoJSON coordinates. Defines how to interpret the coordinates of input geometries. This does not force the dimension of the resulting geometries - the actual geometry dimension will be determined from the parsed data. Use this to:
|
Returns
Geometry<P> | Geometry<P>[]
A new geometry object or an array of new geometry objects
Throws
InvalidGeoJSONErroron GeoJSON feature without geometryInvalidGeoJSONErroron invalid GeoJSON geometry
See also
pointshortcut to createPointgeometrylineStringshortcut to createLineStringgeometrypolygonshortcut to createPolygongeometrymultiPointshortcut to createMultiPointgeometrymultiLineStringshortcut to createMultiLineStringgeometrymultiPolygonshortcut to createMultiPolygongeometrycircularStringshortcut to createCircularStringgeometry
Examples
'layout' option