Skip to content

Embedding resources into GeoJSON features

Andrew Cooke edited this page Sep 9, 2021 · 1 revision

The Geospatial Resource types in this repository have mostly been created without containing their spatial representation - the polygon, line, multi-line, or points that define the object. You may be wondering why this is.

These resources are designed for use within GeoJSON, and RFC-7946 which defines this specification is quite specific about how GeoJSON Features and FeatureCollections should work. In order to support this, it is better that our resources can be embedded within GeoJSON Features rather than the other way around.

There are two commonly used approaches to extend GEOJSON:

  1. Embed additional properties into the properties member of a GeoJSON Feature. This is the recommended approach and is supported by most parsers and tools that read and write GeoJSON collections.
  2. Embed the properties at a slightly higher level in the GeoJSON Feature, so that they form top-level constructs along with the geometry and type members. These are called "foreign members" in the GeoJSON specification. Many GIS tools do just this with their attribute data. However, a number of tools, libraries, and parsers ignore foreign members, or only handle specific foreign members that they explicitly support.

On this basis we decided that we would use the properties member. We add two properties to each GeoJSON Feature:

  • contentType is a string containing the JSON resource name (file name without the .json extension). For instance, a holding would be "contentType": "HoldingResource".
  • content is an object that is the chosen resource type.

You can see an example of this in the code section, under \resources\geojson-AgriculturalContentResource.json.

Clone this wiki locally