GeoJSON format
The GeoJSON format is defined in RFC 7946.
According to the definition, GeoJSON documents come in one of three formats:
Format | Example |
---|---|
A region of space: Simple geometries with a geometry type and coordinates, supporting the types defined by the OpenGIS Simple Feature Implementation: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection |
|
Spatially bounded entities: Feature types, which are geometries along with some attributes; similar to shape files that can include attributes for a shape or to a KML Folder of Placemarks |
|
A list of Features: a FeatureCollection |
|
GeoJSON only supports WGS84, the World Geodetic System 1984. This matches with the default srsid 4326 in Db2 Spatial Analytics.
With Db2 Spatial Analytics, the following mappings are applied to construct a geometry from a
GeoJSON document:
Name | Target types | Example | Comment |
---|---|---|---|
Point |
ST_Point function, ST_Geometry function |
|
|
LineString |
ST_LineString function, ST_Geometry function |
|
|
Polygon |
ST_Polygon function, ST_Geometry function |
|
Can have holes, that is, multiple rings. Linear rings are not required to follow the right-hand rule. |
MultiPoint |
ST_MultiPoint function, ST_Geometry function |
|
|
MultiLineString |
ST_MultiLineString function, ST_Geometry function |
|
|
MultiPolygon |
ST_MultiPolygon function, ST_Geometry function |
|
|
GeometryCollection |
N/A |
|
Nested collections or collections of different types are not supported. |
bbox |
N/A | Ignored. The bounding box values will be calculated from coordinates. | |
coordinates |
[ longitude, latitude (, elevation)](,)* |
|
Using decimal values; elevation (z-value) is optional; if a 4th value is present, it will be treated as a measure m. |
Feature |
A feature contains a single geometry object with the addition of properties. It will therefore be treated like described for the geometry types above. The properties element, and, if it exists, the ‘id’ element will be ignored. |
|
|
FeatureCollection |
One or more features. |
|
Features cannot be of different types. |
Note: The sequence of name-value pairs is irrelevant as long as the general lineup is
syntactically valid. That is, it doesn’t matter whether, for example, a
coordinates
element is listed before or after a properties
element.In Db2 Spatial Analytics, the case of the names will be ignored. For example,
Feature
, FEATURE
, and feature
are all
accepted.
If a geometry type definition misses the coordinates
object, or the
coordinates
object is empty or NULL, the geometry is treated as an empty
geometry.
Restrictions for
FeatureCollection
:- If
FeatureCollection
contains multiple points, multiple linestrings, or multiple polygons, the collection will be stored as the associated multi-geometry type, provided that the target type accepts the multi-geometry. - Features that do not match the first geometry type that is found in
FeatureCollection
will be ignored. A warning will be set for this case.