stac-js

0.0.9

A STAC Asset or Item Asset Definition.

You can access all properties of the given STAC Asset object directly, e.g. asset.href.

new Asset(data: (Object | Asset), key: string, context: (Collection | Item | null))

Extends STACReference

Parameters
data ((Object | Asset)) The STAC Asset object
key (string = null) The asset key
context ((Collection | Item | null) = null) The object that contains the asset
Properties
href (string)
title (string?)
description (string?)
type (string?)
roles (Array<string>?)
Static Members
fromAssets(assets, context)
Instance Members
getObjectType()
isAsset()
getAbsoluteUrl(stringify)
getKey()
getMetadata(field)
getBands()
findVisualBands()
findBand(value, property, bands)
getBand(band)
getMinMaxValues(band)
getNoDataValues(band)
isDefinition()
isHTTP()
hasRole(roles, includeKey)

A STAC Catalog.

You can access all properties of the given STAC Catalog object directly, e.g. catalog.title.

new Catalog(data: Object, absoluteUrl: (string | null))

Extends CatalogLike

Parameters
data (Object) The STAC Catalog object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Catalog
Properties
stac_version (string)
stac_extensions (Array<string>?)
type (string)
id (string)
title (string?)
description (string)
links (Array<Link>)

A STAC Collection.

You can access all properties of the given STAC Collection object directly, e.g. collection.title.

new Collection(data: Object, absoluteUrl: (string | null))

Extends CatalogLike

Parameters
data (Object) The STAC Collection object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Collection
Properties
stac_version (string)
stac_extensions (Array<string>?)
type (string)
id (string)
title (string?)
description (string)
keywords (Array<string>?)
license (string)
providers (Array<Provider>)
extent (Extent)
summaries (Object<string, (Array | Object)>)
links (Array<Link>)
assets (Object<string, Asset>)
Instance Members
toGeoJSON()
getBoundingBox()
getBoundingBoxes()
getRawBoundingBoxes()
getTemporalExtent()
getTemporalExtents()
getSummary(field)
getBands()

CollectionCollection

src/collectioncollection.js

Represents an Collections containing Collections.

new CollectionCollection(data: Object, absoluteUrl: (string | null))

Extends APICollection

Parameters
data (Object) The STAC API Collections object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Item Collection
Properties
collections (Array<Collection>)
links (Array<Link>)
Instance Members
getObjectType()
getAll()
isCollectionCollection()
toGeoJSON()
getBoundingBox()
getBoundingBoxes()
getTemporalExtent()
getTemporalExtents()

A STAC Item.

You can access all properties of the given STAC Item object directly, e.g. item.id or item.properties.datetime.

new Item(data: Object, absoluteUrl: (string | null))

Extends STAC

Parameters
data (Object) The STAC Item object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Item
Properties
stac_version (string)
stac_extensions (Array<string>?)
type (string)
id (string)
geometry ((Object | null))
bbox (Array<number>?)
properties (ItemProperties)
links (Array<Link>)
assets (Object<string, Asset>)
collection (string?)
Instance Members
getObjectType()
toGeoJSON()
getBoundingBox()
getBoundingBoxes()
getDateTime()
getTemporalExtent()
getTemporalExtents()
getMetadata(field)
getBands()

Represents an ItemCollection containing Items.

new ItemCollection(data: Object, absoluteUrl: (string | null))

Extends APICollection

Parameters
data (Object) The STAC Item Collection object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Item Collection
Properties
type (string)
features (Array<Item>)
links (Array<Link>)
Instance Members
getObjectType()
getAll()
toGeoJSON()
getBoundingBox()
getBoundingBoxes()
getTemporalExtent()
getTemporalExtents()

A STAC Link object.

You can access all properties of the given STAC Link object directly, e.g. link.href.

new Link(data: (Object | Link), context: (STAC | null))

Extends STACReference

Parameters
data ((Object | Link)) The STAC Link object
context ((STAC | null) = null) The object that contains the link
Properties
href (string)
rel (string)
type (string?)
title (string?)
method (string?)
headers (Object<string, string>?)
body (Object?)
merge (boolean?)
Static Members
Instance Members
getObjectType()

browserProtocols

src/http.js

Protocols supported by browsers (http and https).

browserProtocols

Type: Array<string>

geojsonMediaType

src/mediatypes.js

The GeoJSON media type.

geojsonMediaType

Type: string

stacMediaTypes

src/mediatypes.js

All STAC media types (JSON + GeoJSON).

stacMediaTypes

Type: Array<string>

browserImageTypes

src/mediatypes.js

All image media types that Web Browsers can show (GIF, JPEG, PNG, WebP).

browserImageTypes

Type: Array<string>

cogMediaTypes

src/mediatypes.js

All Cloud Optimized GeoTiff media types.

cogMediaTypes

Type: Array<string>

geotiffMediaTypes

src/mediatypes.js

All GeoTiff media types (including COG media types).

geotiffMediaTypes

Type: Array<string>

imageMediaTypes

src/mediatypes.js

All image media types combined (Web Browser + GeoTiff).

imageMediaTypes

Type: Array<string>

centerOfBoundingBox

src/geo.js

Returns the center of the STAC entity.

centerOfBoundingBox(bbox: (BoundingBox | null)): (Point | null)
Parameters
bbox ((BoundingBox | null))
Returns
(Point | null):

toGeoJSON

src/geo.js

Converts one or more bounding boxes to a GeoJSON Feature.

The Feature contains a Polygon or MultiPolygon based on the given number of valid bounding boxes.

toGeoJSON(bboxes: (BoundingBox | Array<BoundingBox>)): (Object | null)
Parameters
bboxes ((BoundingBox | Array<BoundingBox>))
Returns
(Object | null):

isBoundingBox

src/geo.js

Checks whether the given thing is a valid bounding box.

A valid bounding box is an array with 4 or 6 numbers that are valid WGS84 coordinates and span a rectangle. See the STAC specification for details.

isBoundingBox(bbox: (BoundingBox | Array<number>)): boolean
Parameters
bbox ((BoundingBox | Array<number>)) A potential bounding box.
Returns
boolean: true if valid, false otherwise

unionBoundingBox

src/geo.js

Compute the union of a list of bounding boxes.

The function ignores any invalid bounding boxes or values for the third dimension.

unionBoundingBox(bboxes: Array<(BoundingBox | null)>): (BoundingBox | null)
Parameters
bboxes (Array<(BoundingBox | null)>)
Returns
(BoundingBox | null):
Related
{isBoundingBox}

isGdalVfsUri

src/http.js

Checks whether a URI is a GDAL Virtual Filesystem URI.

Such an URI usually starts with /vsi (except for /vsicurl/).

isGdalVfsUri(href: string): boolean
Parameters
href (string)
Returns
boolean: true if an GDAL Virtual Filesystem URI, false otherwise.

toAbsolute

src/http.js
toAbsolute(href: string, baseUrl: string, stringify: boolean): (string | URI)
Parameters
href (string)
baseUrl (string)
stringify (boolean = true)
Returns
(string | URI):

normalizeUri

src/http.js
normalizeUri(href: string, baseUrl: (string | null), noParams: boolean, stringify: boolean): (string | URI)
Parameters
href (string)
baseUrl ((string | null) = null)
noParams (boolean = false)
stringify (boolean = true)
Returns
(string | URI):

Checks whether a given media type is in the list of media types.

isMediaType(type: (string | undefined), allowedTypes: (string | Array<string>), allowUndefined: boolean): boolean
Parameters
type ((string | undefined)) The potential media type.
allowedTypes ((string | Array<string>)) A list of allowed media types (or a single media type as string).
allowUndefined (boolean = false) If set to true , returns true if undefined is passed as type .
Returns
boolean: true if the media type is allowed, false otherwise.

isStacMediaType

src/mediatypes.js

Checks whether the given media type is a STAC media type (JSON or GeoJSON).

isStacMediaType(type: (string | undefined), allowUndefined: boolean): boolean
Parameters
type ((string | undefined)) The potential media type.
allowUndefined (boolean = false) If set to true , returns true if undefined is passed as type .
Returns
boolean: true if the media type is a STAC media type, false otherwise.

Checks whether a variable is a string and contains at least one character.

hasText(string: any): boolean
Parameters
string (any) A variable to check.
Returns
boolean: true is the given variable is an string with length > 0, false otherwise.

Checks whether a variable is a real object or not.

This is a more strict version of typeof x === 'object' as this example would also succeeds for arrays and null. This function only returns true for real objects and not for arrays, null or any other data types.

isObject(obj: any): boolean
Parameters
obj (any) A variable to check.
Returns
boolean: true is the given variable is an object, false otherwise.

mergeArraysOfObjects

src/utils.js

Merges any number of arrays of objects.

mergeArraysOfObjects(bands: ...Array<Object>): Array<Object>
Parameters
bands (...Array<Object>)
Returns
Array<Object>:

A STAC API Collection (i.e. an ItemCollection or a CollectionCollection)

You can access all properties of the given STAC Catalog object directly, e.g. collection.links.

Don't instantiate this class!

APICollection

Extends STACHypermedia

Parameters
data (Object) The STAC API Collection object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Item Collection
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Instance Members
getAll()

Class for common parts of Catalogs and Collections.

Don't instantiate this class!

CatalogLike

Extends STAC

Parameters
data (Object) The STAC Catalog or Collection object
absoluteUrl ((string | null) = null) Absolute URL of the STAC Catalog or Collection
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Instance Members
getObjectType()

Parses a UTC-based ISO8601 date and time string to a Date object.

Does not support timezones as all STAC datetime must be given in UTC.

isoToDate(str: any): (Date | null)
Parameters
str (any)
Returns
(Date | null):

centerDateTime

src/datetime.js

Computes the center datetime between two datetimes.

centerDateTime(start: Date, end: Date): Date
Parameters
start (Date) start datetime
end (Date) end datetime
Returns
Date: center datetime

unionDateTime

src/datetime.js

Computes a single interval from multiple temporal intervals.

unionDateTime(list: Array<Array<Date>>): (Array<Date> | null)
Parameters
list (Array<Array<Date>>) A list of temporal intervals
Returns
(Array<Date> | null): The merged temporal interval

STACHypermedia

src/hypermedia.js

STAC Hypermedia class for STAC objects.

Don't instantiate this class!

STACHypermedia

Extends STACObject

Parameters
data (Object) The STAC object
absoluteUrl ((string | null) = null) Absolute URL of the STAC object
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Properties
links (Array<Link>)
Instance Members
getAbsoluteUrl()
setAbsoluteUrl(url)
getStacLinksWithRel(rel, allowUndefined)
getStacLinkWithRel(rel, allowUndefined)
getLinkWithRel(rel)
getLinksWithRels(rels)
getLinksWithOtherRels(rels)

STACObject

src/object.js

Base class for STAC objects.

Don't instantiate this class!

STACObject
Parameters
data (Object) The STAC object
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Instance Members
isItem()
isCatalog()
isCatalogLike()
isCollection()
isItemCollection()
isCollectionCollection()
isAsset()
getObjectType()
getAbsoluteUrl()
getMetadata(field)
toGeoJSON()
getBoundingBox()
getCenter()
getBoundingBoxes()
toJSON()

STACReference

src/reference.js

A STAC reference as base for Assets and Links.

Don't instantiate this class!

STACReference

Extends STACObject

Parameters
data (Object) The STAC API Collection object
context ((STAC | null) = null) The object that contains the link
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Properties
href (string)
type (string?)
Instance Members
getAbsoluteUrl(stringify)
getContext()
canBrowserDisplayImage(allowUndefined)
isType(types)
isGeoTIFF()
isCOG()
isHTTP()

Class for STAC spec entities (Item, Catalog and Collection).

Don't instantiate this class!

STAC

Extends STACHypermedia

Parameters
data (Object) The STAC object
absoluteUrl ((string | null) = null) Absolute URL of the STAC object
keyMap (Object<string, function> = {}) Keys and functions that convert the values to stac-js objects.
privateKeys (Array<string> = []) Keys that are private members of the stac-js objects (for cloning and export).
Instance Members
getTemporalExtent()
getTemporalExtents()
getIcons(allowUndefined)
getThumbnails(browserOnly, prefer)
getDefaultGeoTIFF(httpOnly, cogOnly)
rankGeoTIFFs(httpOnly, cogOnly, roleScores, additionalCriteria)
findVisualAssets()
getAsset(key)
getAssets()
getAssetsWithRoles(roles, includeKey)
getAssetWithRole(role, includeKey)
getAssetsByTypes(types)
equals(other)

Creates the corresponding object for a object that conforms to the STAC specification.

This creates either a Catalog, a Collection or an Item instance. By default it migrates the data to the latest STAC version, but doesn't update the version number.

create(data: Object, migrate: boolean, updateVersionNumber: boolean): (Catalog | Collection | CollectionCollection | Item | ItemCollection)
Parameters
data (Object) The STAC object
migrate (boolean = true) true to migrate to the latest version, false otherwise
updateVersionNumber (boolean = false) true to update the version number (to the latest version), false otherwise. Only applies if migrate is set to true .
Returns
(Catalog | Collection | CollectionCollection | Item | ItemCollection): The created object instance.

BoundingBox

src/types.js

A bounding box (2D oder 3D).

BoundingBox

Type: Array<number>

A point (2D or 3D).

Point

Type: Array<number>

BandWithIndex

src/types.js

A band with the corresponding index.

BandWithIndex

Type: Object

Properties
index (number) : The index in the bands array.
band (Object) : The band object

A data provider.

Provider

Type: Object

Properties
name (string) : The name of the organization or the individual.
description (string?) : Description
roles (Array<string>?) : Roles of the provider. Any of licensor, producer, processor or host.
url (string?) : Homepage

VisualBands

src/asset.js

The RGB bands.

VisualBands

Type: Object

Properties
red (BandWithIndex) : The red band with its index
green (BandWithIndex) : The green band with its index
blue (BandWithIndex) : The blue band with its index

Statistics

src/asset.js

Statistics

Statistics

Type: Object

Properties
minimum ((number | null)) : Minimum value
maximum ((number | null)) : Maximum value

Extents

Extent

Type: Object

Properties
spatial (SpatialExtent) : Spatial extents
temporal (TemporalExtent) : Temporal extents

SpatialExtent

src/collection.js

Spatial Extents

SpatialExtent

Type: Object

Properties
bbox (Array<Array<number>>) : Bounding boxes

TemporalExtent

src/collection.js

Temporal Extents

TemporalExtent

Type: Object

Properties
interval (Array<Array<(string | null)>>) : Intervals

ItemProperties

src/item.js

Metadata for an item, the item properties.

ItemProperties

Type: Object

Properties
datetime (string) : Date and Time

AssetScore

src/stac.js

Object with an asset and the corresponding score.

AssetScore

Type: Object

Properties
asset (Asset)
score (number)

STAC~rankGeoTIFFs

src/stac.js

A function that can influence the score.

Returns a relative addition to the score. Negative values subtract from the score.

STAC~rankGeoTIFFs(asset: Asset)

Type: Function

Parameters
asset (Asset) The asset to calculate the score for.

VisualAssets

src/stac.js

The single-band assets for RGB composites.

VisualAssets

Type: Object

Properties
red (BandWithIndex) : The red band with its index
green (BandWithIndex) : The green band with its index
blue (BandWithIndex) : The blue band with its index