pygeodes.utils.stac.Asset#
- class pygeodes.utils.stac.Asset(href: str, title: str | None = None, description: str | None = None, media_type: str | None = None, roles: List[str] | None = None, extra_fields: Dict[str, Any] | None = None)[source]#
Bases:
Asset
- __init__(href: str, title: str | None = None, description: str | None = None, media_type: str | None = None, roles: List[str] | None = None, extra_fields: Dict[str, Any] | None = None) None [source]#
Methods
__init__
(href[, title, description, ...])clone
()Clones this asset.
copy
(href)Copies this asset's file to a new location on the local filesystem, setting the asset href accordingly.
delete
()Delete this asset's file.
from_dict
(d)Constructs an Asset from a dict.
from_stac_asset
(asset)Gets the absolute href for this asset, if possible.
has_role
(role)Check if a role exists in the Asset role list.
move
(href)Moves this asset's file to a new location on the local filesystem, setting the asset href accordingly.
set_owner
(obj)Sets the owning item of this Asset.
to_dict
()Returns this Asset as a dictionary.
Attributes
Access the asset's common metadata fields as a
CommonMetadata
object.Link to the asset object.
Optional displayed title for clients and users.
A description of the Asset providing additional details, such as how it was processed or created.
Optional description of the media type.
Optional, Semantic roles (i.e.
The
Item
orCollection
that this asset belongs to, orNone
if it has no owner.Optional, additional fields for this asset.
- clone() Asset [source]#
Clones this asset. Makes a
deepcopy
of theextra_fields
.- Returns:
Asset: The clone of this asset.
- property common_metadata: CommonMetadata#
Access the asset’s common metadata fields as a
CommonMetadata
object.
- copy(href: str) Asset [source]#
Copies this asset’s file to a new location on the local filesystem, setting the asset href accordingly.
Modifies the asset in place, and returns the same asset.
- Args:
- href: The new asset location. Must be a local path. If relative
it must be relative to the owner object.
- Returns:
Asset: The asset with the updated href.
- delete() None [source]#
Delete this asset’s file. Does not delete the asset from the item that owns it. See
delete_asset()
for that.Does not modify the asset.
- description: str | None#
A description of the Asset providing additional details, such as how it was processed or created. CommonMark 0.29 syntax MAY be used for rich text representation.
- extra_fields: Dict[str, Any]#
Optional, additional fields for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON.
- classmethod from_dict(d: Dict[str, Any]) A [source]#
Constructs an Asset from a dict.
- Returns:
Asset: The Asset deserialized from the JSON dict.
- get_absolute_href() str | None [source]#
Gets the absolute href for this asset, if possible.
- If this Asset has no associated Item, and the asset HREF is a relative path,
this method will return
None
. If the Item that owns the Asset has no self HREF, this will also returnNone
.- Returns:
- str: The absolute HREF of this asset, or None if an absolute HREF could not
be determined.
- has_role(role: str) bool [source]#
Check if a role exists in the Asset role list.
- Args:
role: Role to check for existence.
- Returns:
bool: True if role exists, else False.
- href: str#
Link to the asset object. Relative and absolute links are both allowed.
- media_type: str | None#
Optional description of the media type. Registered Media Types are preferred. See
MediaType
for common media types.
- move(href: str) Asset [source]#
Moves this asset’s file to a new location on the local filesystem, setting the asset href accordingly.
Modifies the asset in place, and returns the same asset.
- Args:
- href: The new asset location. Must be a local path. If relative
it must be relative to the owner object.
- Returns:
Asset: The asset with the updated href.
- owner: Item | Collection | None#
The
Item
orCollection
that this asset belongs to, orNone
if it has no owner.
- roles: List[str] | None#
Optional, Semantic roles (i.e. thumbnail, overview, data, metadata) of the asset.
- set_owner(obj: Collection | Item) None [source]#
Sets the owning item of this Asset.
The owning item will be used to resolve relative HREFs of this asset.
- Args:
obj: The Collection or Item that owns this asset.
- title: str | None#
Optional displayed title for clients and users.