Assets in SDK

Retrieve and manage assets using the SDK.


Overview

Get assets and STAC objects from orders.

View repository

Class: AssetSorting

A class that provides sorting options for assets.

Attributes

AttributeDescription
nameutils.SortingField
Sorts by asset name. The default order is ascending.
titleutils.SortingField
Sorts by title. The default order is ascending.
sizeutils.SortingField
Sorts by size. The default order is ascending.
created_atutils.SortingField
Sorts by creation date. The default order is ascending.
updated_atutils.SortingField
Sorts by update date. The default order is ascending.
sourceutils.SortingField
Sorts by source. The default order is ascending.
collection_nameutils.SortingField
Sorts by collection name. The default order is ascending.
producer_nameutils.SortingField
Sorts by producer name. The default order is ascending.
Python
from itertools import islice
# Sort by name, in ascending alphabetical order (A to Z)
assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.name)
16 collapsed lines
# Sort by title, in ascending alphabetical order (A to Z)
# assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.title)
# Sort by size, in descending order (largest to smallest)
# assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.size.desc)
# Sort by creation date, in descending order (most recent to earliest)
# assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.created_at.desc)
# Sort by source, in ascending alphabetical order (A to Z)
# assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.source)
# Sort by collection name, in ascending alphabetical order (A to Z)
# assets_sorted = up42.Asset.all(sort_by=up42.AssetSorting.collection_name)
# Define output for one of the sorting examples
for asset in islice(assets_sorted, 0, 5): # Print first 5 results
print(f"- Asset name: {asset.name}")
print(f" Creation date: {asset.created_at}")
print(f" Source: {asset.source}")
print(f" Collection name: {asset.collection_name}\n")

Class: Asset

A data class that enables access to assets.

Attributes

AttributeDescription
idstr
The asset ID.
account_idstr
The account ID.
created_atstr
The timestamp when the asset was created.
nameOptional[str]
The file name.
sizeint
The asset size.
updated_atstr
The timestamp when the asset was last updated.
workspace_idstr
The workspace ID.
order_idOptional[str]
The order ID.
sourceOptional[Literal[“ARCHIVE”, “TASKING”, “PROCESSING”]]
The asset source.
product_idOptional[str]
The data product ID.
content_typestr
The asset file format.
producer_nameOptional[str]
The company that initially acquired and processed the source data.
collection_nameOptional[str]
The geospatial collection name.
geospatial_metadata_extraction_statusOptional[Literal[“SUCCESSFUL”, “FAILED”, “IN_PROGRESS”, “NOT_PROCESSED”]]
The status indicating the progress and outcome of transforming the asset’s metadata for CNAM compatibility.
titleOptional[str]
The asset title.
tagsOptional[list[str]]
A list of tags that categorize the asset. A tag can consist of letters, numbers, spaces, and special characters (., -, _, /, :).
Python
# Select an asset
asset_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch asset info
asset = up42.Asset.get(asset_id)
# Define output
print(f"Asset details for ID: {order.id}")
print(f"Asset filename: {asset.name}")
print(f"User title: {asset.title}")
print(f"Collection name: {asset.collection_name}")
print(f"Size: {asset.size}")
print(f"Filetype: {asset.content_type}")
print(f"Order ID: {asset.order_id}")
print(f"Asset tags: {', '.join(asset.tags) if asset.tags else 'No tags'}")

Properties

asset_id

This property is deprecated and will be removed in 3.0.0.

Retrieves the ID of the asset. Returns str.

Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Fetch asset info
asset = up42.Asset.get(asset_id=asset_id)
asset.asset_id

stac_items

This property is deprecated and will be removed in 3.0.0. Use pystac.Client.search instead.

Retrieves STAC items associated with a specific asset. Returns pystac.ItemCollection.

Python
import pandas as pd
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Retrieve the ItemCollection object and extract the properties
stac_items = up42.Asset.get(asset_id).stac_items
item_properties = [item.properties for item in stac_items]
# Create and display a DataFrame
df = pd.DataFrame(item_properties)
df

stac_info

This property is deprecated and will be removed in 3.0.0. Don’t retrieve tags with stac_info as it might return outdated information. Use pystac.Client.get_item instead.

Retrieves the STAC collection associated with a specific asset. Returns Union[pystac.Collection, pystac_client.CollectionClient].

Python
import pandas as pd
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Retrieve STAC info and convert it to a dictionary
stac_info_dict = up42.Asset.get(asset_id).stac_info.to_dict()
# Create and display a DataFrame
df = pd.json_normalize(stac_info_dict)
df

file

This property is deprecated and will be removed in 3.0.0. Use pystac.Asset.file instead.

Retrieves an asset file. Returns a utils.ImageFile instance.

Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Retrieve asset file
file = up42.Asset.get(asset_id).file
# Define output
print(f"URL: {file.url}")
print(f"Name: {file.file_name}")

Methods

get

This method is deprecated and will be removed in 3.0.0.

Fetches a specific asset by its ID. Returns Asset.

ParameterDescription
asset_idstr
The asset ID.
Python
# Select an asset
asset_id = "d290f1ee-6c54-4b01-90e6-d701748f0851"
# Fetch asset info
asset = up42.Asset.get(asset_id)
# Define output
print(f"Asset details for ID: {order.id}")
print(f"Asset filename: {asset.name}")
print(f"User title: {asset.title}")
print(f"Collection name: {asset.collection_name}")
print(f"Size: {asset.size}")
print(f"Filetype: {asset.content_type}")
print(f"Order ID: {asset.order_id}")
print(f"Asset tags: {', '.join(asset.tags) if asset.tags else 'No tags'}")

all

This method is deprecated and will be removed in 3.0.0.

Retrieves all assets, with optional filtering. Returns Iterator["Asset"]. Use itertools.islice to offset and limit the results.

ParameterDescription
created_afterOptional[Union[str, dt.datetime]]
A time condition for search. Use to search for assets created after the timestamp specified in the YYYY-MM-DD format.
created_beforeOptional[Union[str, dt.datetime]]
A time condition for search. Use to search for assets created before the timestamp specified in the YYYY-MM-DD format.
workspace_idOptional[str]
The workspace ID. Use to get assets from a specific workspace. Otherwise, assets from the entire account will be returned.
collection_namesOptional[List[str]]
The names of geospatial collections. Use to search for assets from any of the provided collections.
producer_namesOptional[List[str]]
The names of producers. Use to search for assets from any of the provided producers. A producer is the type of geospatial collection provider that initially acquired and processed the source data. Data acquired by a producer can be distributed to various hosts.
tagsOptional[List[str]]
Asset tags. Use to search for assets with any of the provided tags. A tag can consist of letters, numbers, spaces, and special characters (., -, _, /, :).
sourcesOptional[List[str]]
Asset sources. Use to search for assets from any of the provided sources.
searchOptional[str]
Additional search terms. Use to search for assets that partially or fully match the provided query in their name, title, or order ID.
sort_byOptional[utils.SortingField]
The results sorting method that arranges elements in ascending or descending order based on a chosen field. To view the list of possible values, see AssetSorting.
Python
from itertools import islice
# Search for assets
assets = up42.Asset.all(
collection_names=["phr", "spot"],
sort_by=up42.AssetSorting.created_at.desc,
)
# Define output
for asset in islice(assets, 0, 5): # Print first 5 results
print(f"- Asset ID: {asset.id}")
print(f" Asset filename: {asset.name}")
print(f" User title: {asset.title}")
print(f" Collection name: {asset.collection_name}")
print(f" Size: {asset.size}")
print(f" Filetype: {asset.content_type}")
print(f" Order ID: {asset.order_id}")
print(f" Asset tags: {', '.join(asset.tags) if asset.tags else 'No tags'}\n")

update_metadata

This method is deprecated and will be removed in 3.0.0. Use pystac.Item.update.

Updates the title and tags of an asset. Returns dict.

ParameterDescription
titleUnion[Optional[str], object]
An editable asset title. If no value is provided, the current title will remain unchanged.
tagsUnion[Optional[List[str]], object]
An editable list of tags to categorize the asset. A tag can consist of letters, numbers, spaces, and special characters (., -, _, /, :). If no value is provided, the current tags will remain unchanged.
Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Initialize asset
asset = up42.initialize_asset(asset_id)
# Update asset metadata
asset.update_metadata(
title="Sentinel-2 over Western Europe",
tags=["optical", "WEU"],
)

get_stac_asset_url

This method is deprecated and will be removed in 3.0.0. Use pystac.Asset.file.url.

Generates a signed download URL for a STAC asset. The generated URL can be used for up to 5 minutes to download the asset without authentication. Returns str.

ParameterDescription
stac_assetpystac.Asset
The STAC asset link in the following format: https://api.sa.up42.com/v2/assets/stac/collections/{collection-id}/items/{item-id}
Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Initialize asset
asset = up42.initialize_asset(asset_id)
# Get STAC asset link
stac_asset=asset.stac_items.items[0].assets.get("b01.tiff")
# Get download URL
asset.get_stac_asset_url(stac_asset)

download

This method is deprecated and will be removed in 3.0.0. Use pystac.Asset.file.download.

Downloads assets from storage and returns a list of download paths. Returns List[str].

ParameterDescription
output_directoryUnion[str, pathlib.Path, None]
The file output directory. The default value is the current directory.
unpackingbool
Determines how to download the asset:
  • True: Downloads and unpacks the file.
  • False: Downloads the compressed file.
The default value is True.
Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Initialize asset
asset = up42.initialize_asset(asset_id)
# Download asset
asset.download(
output_directory="/Users/max.mustermann/Desktop/",
unpacking=False,
)

download_stac_asset

This method is deprecated and will be removed in 3.0.0. Use pystac.Asset.file.download.

Downloads a STAC asset from storage and provides the path to the downloaded file. A new directory for the file will be created. Returns pathlib.Path.

ParameterDescription
stac_assetpystac.Asset
The STAC asset link in the following format: https://api.sa.up42.com/v2/assets/stac/collections/{collection-id}/items/{item-id}
output_directoryUnion[str, pathlib.Path, None]
The file output directory. The default value is the current directory.
Python
# Select an asset
asset_id = "3bf00b63-7188-4b04-aa27-d78e4cd32c01"
# Initialize asset
asset = up42.initialize_asset(asset_id)
# Get STAC asset link
stac_asset=asset.stac_items.items[0].assets.get("b01.tiff")
# Download STAC asset
asset.download_stac_asset(
stac_asset,
output_directory="/Users/max.mustermann/Desktop/",
)

Learn more


Last updated: