stac

package module
v0.25.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

STAC Utilities

Utilities for working with Spatio-Temporal Asset Catalog (STAC) resources.

Go Reference Tests

The stac command line utility can be used to crawl and validate STAC metadata. In addition, the github.com/planetlabs/go-stac module can be used in Go projects.

Command Line Interface

The stac program can be installed by downloading one of the archives from the latest release.

Extract the archive and place the stac executable somewhere on your path. See a list of available commands by running stac in your terminal.

Mac users can install the stac program with brew:

brew install planetlabs/tap/go-stac
CLI Usage

Run stac help to see a full list of commands and their arguments. The primary stac commands are documented below.

stac validate

The stac validate command crawls STAC resources and validates them against the appropriate schema.

Example use:

stac validate --entry path/to/catalog.json

The --entry can be a file path or URL pointing to a catalog, collection, or item. By default, all catalogs, collections, and items linked from the entry point will be validated. Use the --no-recursion option to validate a single resource without crawling to linked resources. See stac validate --help for a full list of supported options.

stac stats

The stac stats command crawls STAC resources and prints out counts of resource type, versions, extensions, asset types, and conformance classes (for API endpoints).

Example use:

stac stats --entry path/to/catalog.json

The --entry can be a file path or URL pointing to a catalog, collection, or item. The stats output is a JSON object with top-level properties for catalog, collection, and item stats.

The structure of the output conforms with the schema of the STAC Stats extension, so the results can be added to a STAC entrypoint to provide stats on child catalogs, collections, and items. The stac stats command can write out a copy of the provided entrypoint with statistics added.

To write out a version of a catalog or collection that includes metadata for the STAC Stats extension, run the following:

stac stats --entry path/to/catalog.json --output path/to/catalog-with-stats.json

Library Use

Requires Go >= 1.18

Install the module into your project.

go get github.com/planetlabs/go-stac

See the reference documentation for example usage in a Golang project.

Development

See the development doc for information on developing and releasing the go-stac library.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeExtendedAsset added in v0.24.0

func DecodeExtendedAsset(assetExtension Extension, assetMap map[string]any) error

func DecodeExtendedItemProperties added in v0.24.0

func DecodeExtendedItemProperties(itemExtension Extension, itemMap map[string]any) error

func EncodeAssets added in v0.24.0

func EncodeAssets(assets map[string]*Asset) (map[string]any, []string, error)

func EncodeExtendedAsset added in v0.24.0

func EncodeExtendedAsset(assetExtension Extension, assetMap map[string]any) error

func EncodeExtendedItemProperties added in v0.24.0

func EncodeExtendedItemProperties(itemExtension Extension, itemMap map[string]any) error

func GetExtensionUris added in v0.24.0

func GetExtensionUris(data map[string]any) ([]string, error)

func IsCoreItemProperty

func IsCoreItemProperty(prop string) bool

func PopulateExtensionFromProperties

func PopulateExtensionFromProperties(extension Extension, properties map[string]any) error

func RegisterAssetExtension added in v0.24.0

func RegisterAssetExtension(pattern *regexp.Regexp, provider ExtensionProvider)

func RegisterCollectionExtension added in v0.24.0

func RegisterCollectionExtension(pattern *regexp.Regexp, provider ExtensionProvider)

func RegisterItemExtension added in v0.24.0

func RegisterItemExtension(pattern *regexp.Regexp, provider ExtensionProvider)

func SetExtensionUris added in v0.24.0

func SetExtensionUris(data map[string]any, uris []string)

Types

type Asset

type Asset struct {
	Type        string      `json:"type,omitempty"`
	Href        string      `json:"href,omitempty"`
	Title       string      `json:"title,omitempty"`
	Description string      `json:"description,omitempty"`
	Created     string      `json:"created,omitempty"`
	Roles       []string    `json:"roles,omitempty"`
	Extensions  []Extension `json:"-"`
}

type Catalog

type Catalog struct {
	Version     string   `json:"stac_version"`
	Id          string   `json:"id"`
	Title       string   `json:"title,omitempty"`
	Description string   `json:"description"`
	Links       []*Link  `json:"links"`
	ConformsTo  []string `json:"conformsTo,omitempty"`
}

func (Catalog) MarshalJSON

func (catalog Catalog) MarshalJSON() ([]byte, error)

type Collection

type Collection struct {
	Version     string            `json:"stac_version"`
	Id          string            `json:"id"`
	Title       string            `json:"title,omitempty"`
	Description string            `json:"description"`
	Keywords    []string          `json:"keywords,omitempty"`
	License     string            `json:"license"`
	Providers   []*Provider       `json:"providers,omitempty"`
	Extent      *Extent           `json:"extent"`
	Summaries   map[string]any    `json:"summaries,omitempty"`
	Links       []*Link           `json:"links"`
	Assets      map[string]*Asset `json:"assets,omitempty"`
	Extensions  []Extension       `json:"-"`
}

func (Collection) MarshalJSON

func (collection Collection) MarshalJSON() ([]byte, error)

func (*Collection) UnmarshalJSON added in v0.24.0

func (collection *Collection) UnmarshalJSON(data []byte) error

type CollectionsList

type CollectionsList struct {
	Collections []*Collection `json:"collections"`
	Links       []*Link       `json:"links"`
}

type Extension added in v0.24.0

type Extension interface {
	URI() string
	Encode(map[string]any) error
	Decode(map[string]any) error
}

func GetAssetExtension added in v0.24.0

func GetAssetExtension(uri string) Extension

func GetCollectionExtension added in v0.24.0

func GetCollectionExtension(uri string) Extension

func GetItemExtension added in v0.24.0

func GetItemExtension(uri string) Extension

type ExtensionProvider added in v0.24.0

type ExtensionProvider func() Extension

type Extent

type Extent struct {
	Spatial  *SpatialExtent  `json:"spatial,omitempty"`
	Temporal *TemporalExtent `json:"temporal,omitempty"`
}

type Item

type Item struct {
	Version    string            `json:"stac_version"`
	Id         string            `json:"id"`
	Geometry   any               `json:"geometry"`
	Bbox       []float64         `json:"bbox,omitempty"`
	Properties map[string]any    `json:"properties"`
	Links      []*Link           `json:"links"`
	Assets     map[string]*Asset `json:"assets"`
	Collection string            `json:"collection,omitempty"`
	Extensions []Extension       `json:"-"`
}

func (Item) MarshalJSON

func (item Item) MarshalJSON() ([]byte, error)

func (*Item) UnmarshalJSON added in v0.24.0

func (item *Item) UnmarshalJSON(data []byte) error

type ItemsList

type ItemsList struct {
	Type  string  `json:"type"`
	Items []*Item `json:"features"`
	Links []*Link `json:"links,omitempty"`
}
type Link struct {
	Href             string         `mapstructure:"href"`
	Rel              string         `mapstructure:"rel"`
	Type             string         `mapstructure:"type,omitempty"`
	Title            string         `mapstructure:"title,omitempty"`
	AdditionalFields map[string]any `mapstructure:",remain"`
}

func (*Link) MarshalJSON added in v0.20.0

func (link *Link) MarshalJSON() ([]byte, error)

func (*Link) UnmarshalJSON added in v0.20.0

func (link *Link) UnmarshalJSON(data []byte) error

type Provider

type Provider struct {
	Name        string   `json:"name"`
	Description string   `json:"description,omitempty"`
	Roles       []string `json:"roles,omitempty"`
	Url         string   `json:"url,omitempty"`
}

type SpatialExtent

type SpatialExtent struct {
	Bbox [][]float64 `json:"bbox"`
}

type TemporalExtent

type TemporalExtent struct {
	Interval [][]any `json:"interval"`
}

Directories

Path Synopsis
cmd
stac
The stac program is a command line tool for working with STAC resources.
The stac program is a command line tool for working with STAC resources.
Package crawler implements a STAC resource crawler.
Package crawler implements a STAC resource crawler.
extensions
eo
pl
sar
internal
Package validator implements a STAC resource validation.
Package validator implements a STAC resource validation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL