data-types: Description of GeoJSON data types

data-typesR Documentation

Description of GeoJSON data types

Description

GeoJSON types based on https://tools.ietf.org/html/rfc7946

GeoJSON object

GeoJSON always consists of a single object. This object (referred to as the GeoJSON object below) represents a geometry, feature, or collection of features.

  • The GeoJSON object may have any number of members (name/value pairs).

  • The GeoJSON object must have a member with the name "type". This member's value is a string that determines the type of the GeoJSON object.

  • The value of the type member must be one of: "Point", "MultiPoint", "LineString", "MultiLineString", "Polygon", "MultiPolygon", "GeometryCollection", "Feature", or "FeatureCollection". The case of the type member values must be as shown here.

  • A GeoJSON object may have an optional "crs" member, the value of which must be a coordinate reference system object (see 3. Coordinate Reference System Objects).

  • A GeoJSON object may have a "bbox" member, the value of which must be a bounding box array (see 4. Bounding Boxes).

Geometry

A Geometry object represents points, curves, and surfaces in coordinate space. Every Geometry object is a GeoJSON object no matter where it occurs in a GeoJSON text.

  • The value of a Geometry object's "type" member MUST be one of the seven geometry types (see Section 1.4).

  • A GeoJSON Geometry object of any type other than "GeometryCollection" has a member with the name "coordinates". The value of the "coordinates" member is an array. The structure of the elements in this array is determined by the type of geometry. GeoJSON processors MAY interpret Geometry objects with empty "coordinates" arrays as null objects.

Point

For type "Point", the "coordinates" member must be a single position.

Example JSON: { "type": "Point", "coordinates": [100.0, 0.0] }

In lawn: lawn_point(c(1, 2))

See: lawn_point

MultiPoint

For type "MultiPoint", the "coordinates" member must be an array of positions.

Example JSON: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

See: lawn_multipoint

Polygon

For type "Polygon", the "coordinates" member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes.

Example JSON: { "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]] }

In lawn: lawn_polygon(list(list(c(-2, 52), c(-3, 54), c(-2, 53), c(-2, 52))))

See: lawn_polygon

MultiPolygon

For type "MultiPolygon", the "coordinates" member must be an array of Polygon coordinate arrays.

Example JSON:

{ "type": "MultiPolygon", "coordinates": [ [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] }

See: lawn_multipolygon

LineString

For type "LineString", the "coordinates" member must be an array of two or more positions. A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points). Though a LinearRing is not explicitly represented as a GeoJSON geometry type, it is referred to in the Polygon geometry type definition.

Example JSON: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

In lawn: lawn_linestring(list(c(-2, 52), c(-3, 54), c(-2, 53)))

See: lawn_linestring

MultiLineString

For type "MultiLineString", the "coordinates" member must be an array of LineString coordinate arrays.

Example JSON: { "type": "MultiLineString", "coordinates": [ [[ -105, 39 ], [ -105, 39 ]], [[ -105, 39 ], [ -105, 39 ]] ] }

See: lawn_multilinestring

Feature

A GeoJSON object with the type "Feature" is a feature object:

  • A feature object must have a member with the name "geometry". The value of the geometry member is a geometry object as defined above or a JSON null value.

  • A feature object must have a member with the name "properties". The value of the properties member is an object (any JSON object or a JSON null value).

  • If a feature has a commonly used identifier, that identifier should be included as a member of the feature object with the name "id".

See: lawn_feature

FeatureCollection

A GeoJSON object with the type "FeatureCollection" is a feature collection object. An object of type "FeatureCollection" must have a member with the name "features". The value corresponding to "features" is an array. Each element in the array is a feature object as defined above.

In lawn: lawn_featurecollection(lawn_point(c(-75, 39)))

See: lawn_featurecollection

GeometryCollection

Each element in the geometries array of a GeometryCollection is one of the geometry objects described above.

Example JSON: { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] }

See: lawn_geometrycollection


ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.