Skip to content

Commit

Permalink
Allow to be used for assets #12, fix item example
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jul 26, 2022
1 parent dc04937 commit 037e12e
Show file tree
Hide file tree
Showing 5 changed files with 222 additions and 49 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Fields can also be used in assets. [#12](https://github.com/stac-extensions/datacube/issues/12)

### Changed

- Clarified that `values` must be an ordered list and not a set of unordered values. [#11](https://github.com/stac-extensions/datacube/issues/11)
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ It specifies datacube related metadata, especially their dimensions and potentia
- [JSON Schema](json-schema/schema.json)
- [Changelog](./CHANGELOG.md)

## Item Properties and Collection Fields

These fields may be added to either [Item](https://github.com/radiantearth/stac-spec/tree/master/item-spec/item-spec.md)
Properties or a [Collection](https://github.com/radiantearth/stac-spec/tree/master/collection-spec/collection-spec.md).
## Fields

The following fields can be used in the following parts of a STAC document:
- [ ] Catalogs
- [x] Collections
- [x] Item Properties (incl. Summaries in Collections)
- [x] Assets (both Collections and Items, incl. Item Asset Definitions in Collections)
- [ ] Links

| Field Name | Type | Description |
| ---------------- | -------------------------------------------------- | ------------------------------------------- |
Expand Down
38 changes: 19 additions & 19 deletions examples/item.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,26 @@
"blue"
]
}
}
},
"cube:variables": {
"temp": {
"dimensions": [
"time",
"y",
"x",
"pressure_levels"
],
"type": "data"
},
"color": {
"dimensions": [],
"type": "auxiliary",
"values": [
"red",
"green",
"blue"
]
"cube:variables": {
"temp": {
"dimensions": [
"time",
"y",
"x",
"pressure_levels"
],
"type": "data"
},
"color": {
"dimensions": [],
"type": "auxiliary",
"values": [
"red",
"green",
"blue"
]
}
}
},
"assets": {
Expand Down
140 changes: 140 additions & 0 deletions examples/item_asset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{
"stac_version": "1.0.0",
"stac_extensions": [
"https://stac-extensions.github.io/datacube/v2.0.0/schema.json"
],
"id": "datacube-123",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-122.308150179,
37.488035566
],
[
-122.597502109,
37.538869539
],
[
-122.576687533,
37.613537207
],
[
-122.2880486,
37.562818007
],
[
-122.308150179,
37.488035566
]
]
]
},
"bbox": [
-122.59750209,
37.48803556,
-122.2880486,
37.613537207
],
"properties": {
"title": "Multi-dimensional data cube 123 in a STAC Item.",
"datetime": "2016-05-03T13:21:30.040Z"
},
"assets": {
"data": {
"href": "http://cool-sat.com/catalog/datacube-123/data.nc",
"type": "application/netcdf",
"title": "netCDF Data cube",
"cube:dimensions": {
"x": {
"type": "spatial",
"axis": "x",
"extent": [
-122.59750209,
-122.2880486
],
"reference_system": 4326
},
"y": {
"type": "spatial",
"axis": "y",
"extent": [
37.48803556,
37.613537207
],
"reference_system": 4326
},
"pressure_levels": {
"type": "spatial",
"axis": "z",
"extent": [
0,
1000
],
"step": 100,
"unit": "Pa"
},
"metered_levels": {
"type": "spatial",
"axis": "z",
"values": [
0,
10,
25,
50,
100,
1000
],
"unit": "m"
},
"time": {
"type": "temporal",
"values": [
"2016-05-03T13:21:30.040Z"
]
},
"spectral": {
"type": "bands",
"values": [
"red",
"green",
"blue"
]
}
},
"cube:variables": {
"temp": {
"dimensions": [
"time",
"y",
"x",
"pressure_levels"
],
"type": "data"
},
"color": {
"dimensions": [],
"type": "auxiliary",
"values": [
"red",
"green",
"blue"
]
}
}
},
"thumbnail": {
"href": "http://cool-sat.com/catalog/datacube-123/thumbnail.png",
"type": "image/png",
"title": "Thumbnail"
}
},
"links": [
{
"rel": "self",
"href": "http://cool-sat.com/catalog/datacube-123/item.json"
}
]
}
77 changes: 51 additions & 26 deletions json-schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,66 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://stac-extensions.github.io/datacube/v2.0.0/schema.json",
"title": "Datacube Extension",
"description": "Datacube Extension for STAC Items and STAC Collections.",
"description": "STAC Datacube Extension for STAC Items and STAC Collections.",
"oneOf": [
{
"$comment": "This is the schema for STAC Items. Remove this object if this extension only applies to Collections.",
"$comment": "This is the schema for STAC Items.",
"allOf": [
{
"$ref": "#/definitions/stac_extensions"
},
{
"type": "object",
"required": [
"type",
"properties",
"assets"
"type"
],
"properties": {
"type": {
"const": "Feature"
},
}
}
},
{
"$ref": "#/definitions/stac_extensions"
}
],
"anyOf": [
{
"type": "object",
"required": [
"properties"
],
"properties": {
"properties": {
"allOf": [
{
"$comment": "Require fields here for Item Properties.",
"required": [
"cube:dimensions"
]
"$ref": "#/definitions/require_field"
},
{
"$ref": "#/definitions/fields"
}
]
},
}
}
},
{
"$comment": "This validates the fields in Item Assets.",
"required": [
"assets"
],
"properties": {
"assets": {
"$comment": "This validates the fields in Item Assets, but does not require them.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/fields"
"not": {
"additionalProperties": {
"not": {
"allOf": [
{
"$ref": "#/definitions/require_field"
},
{
"$ref": "#/definitions/fields"
}
]
}
}
}
}
}
Expand All @@ -65,21 +88,18 @@
],
"anyOf": [
{
"$comment": "This is the schema for the top-level fields in a Collection. Remove this if this extension does not define top-level fields for Collections.",
"$comment": "This is the schema for the top-level fields in a Collection.",
"allOf": [
{
"$comment": "Require fields here for Collections (top-level).",
"required": [
"cube:dimensions"
]
"$ref": "#/definitions/require_field"
},
{
"$ref": "#/definitions/fields"
}
]
},
{
"$comment": "This validates the fields in Collection Assets, but does not require them.",
"$comment": "This validates the fields in Collection Assets.",
"required": [
"assets"
],
Expand All @@ -91,7 +111,7 @@
"not": {
"allOf": [
{
"$ref": "#/definitions/require_any_field"
"$ref": "#/definitions/require_field"
},
{
"$ref": "#/definitions/fields"
Expand All @@ -104,7 +124,7 @@
}
},
{
"$comment": "This is the schema for the fields in Item Asset Definitions. It doesn't require any fields.",
"$comment": "This is the schema for the fields in Item Asset Definitions.",
"required": [
"item_assets"
],
Expand Down Expand Up @@ -164,6 +184,11 @@
{"required": ["cube:variables"]}
]
},
"require_field": {
"required": [
"cube:dimensions"
]
},
"fields": {
"$comment": "Add your new fields here. Don't require them here, do that above in the corresponding schema.",
"type": "object",
Expand Down Expand Up @@ -522,4 +547,4 @@
"type": "string"
}
}
}
}

0 comments on commit 037e12e

Please sign in to comment.