View Source StacValidator (StacValidator v0.1.1)

StacValidator provides functions for validating Spatio-Temporal Asset Catalog (STAC) metadata against the STAC specification.

Summary

Functions

Validates a STAC item, collection, or catalog against the STAC specification.

Functions

Link to this function

validate(item, opts \\ [])

View Source

Validates a STAC item, collection, or catalog against the STAC specification.

Examples

Validating a STAC Item:

iex> StacValidator.validate(%{
...>   "type" => "Feature",
...>   "stac_version" => "1.0.0",
...>   "id" => "example-item",
...>   "geometry" => nil,
...>   "properties" => %{
...>     "datetime" => "2024-01-01T00:00:00Z"
...>   },
...>   "links" => [],
...>   "assets" => %{}
...> })
{:ok, true}

Validating a STAC Collection:

iex> StacValidator.validate(%{
...>   "type" => "Collection",
...>   "stac_version" => "1.0.0",
...>   "id" => "example-collection",
...>   "description" => "A collection of STAC items",
...>   "license" => "other",
...>   "extent" => %{
...>     "spatial" => %{
...>       "bbox" => [[-180.0, -90.0, 180.0, 90.0]]
...>     },
...>     "temporal" => %{
...>       "interval" => [["2020-01-01T00:00:00Z", nil]]
...>     }
...>   },
...>   "links" => []
...> })
{:ok, true}

Validating a STAC Catalog:

iex> StacValidator.validate(%{
...>   "type" => "Catalog",
...>   "stac_version" => "1.0.0",
...>   "id" => "example-catalog",
...>   "description" => "A catalog of STAC collections and items",
...>   "links" => [
...>     %{
...>       "rel" => "child",
...>       "href" => "collection.json",
...>       "type" => "application/json"
...>     }
...>   ]
...> })
{:ok, true}