Client
Parameters
str
required
The URL of the STAC API to connect to.
Optional[dict]
default:"None"
Optional dictionary of HTTP headers to include in requests.
Can be used for authentication or custom headers.
get_collection()
Parameters
str
required
The ID of the collection to retrieve. Example: “aster-l1t”
Returns
An instance of the CollectionClient class for the specified collection.
get_collection_from_catalog()
Returns
The root catalog of the STAC API.
open()
Parameters
str
required
The URL of the STAC API to connect to. Example: “https://planetarycomputer.microsoft.com/api/stac/v1”
Optional[dict]
default:"None"
Optional dictionary of HTTP headers for authentication.
Example: {“Authorization”: “Bearer token123”}
Returns
An instance of the Client class connected to the specified URL.Example usage:
Without authentication
client = Client.open(“https://planetarycomputer.microsoft.com/api/stac/v1”)With custom headers
client = Client.open( “https://example.com/stac/v1”, headers={“Authorization”: “Bearer token123”} )Using convenience methods
client = Client.open(“https://example.com/stac/v1”) client.with_basic_auth(“username”, “password”)search()
Parameters
Union[str, list]
A variable number of item IDs to filter the items.
Example: “item_id1” or [“item_id1”, “item_id2”]
Optional[str]
default:"None"
The ID of the collection to search in.
Example: “aster-l1t”
Optional[list]
default:"None"
A list of bounding boxes for filtering the items.
Each bounding box is represented as a list of four float values: [min_lon, min_lat, max_lon, max_lat].
Example: [[-180.0, -90.0, 180.0, 90.0]] # This bounding box covers the entire world.
Optional[Union[str, BaseGeometry, List[Union[str, BaseGeometry]]]]
default:"None"
Shapely geometry object(s) or WKT string(s) for spatial filtering.
Can be a single geometry, WKT string, or a list of geometries/WKT strings.
If both bbox and geometry are provided, geometry takes precedence.
Example: Polygon(…) or “POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))” or [Polygon(…), Polygon(…)]
Optional[Union[str, python_datetime.datetime, list]]
default:"None"
A single datetime, RFC 3339-compliant timestamp,
or a list of date-time ranges for filtering the items. The datetime can be specified in various formats:
- “YYYY” expands to [“YYYY-01-01T00:00:00Z”, “YYYY-12-31T23:59:59.999999Z”]
- “YYYY-mm” expands to [“YYYY-mm-01T00:00:00Z”, “YYYY-mm-<last_day>T23:59:59.999999Z”]
- “YYYY-mm-dd” expands to [“YYYY-mm-ddT00:00:00Z”, “YYYY-mm-ddT23:59:59.999999Z”]
- “YYYY-mm-ddTHH:MM:SSZ” remains as [“YYYY-mm-ddTHH:MM:SSZ”, “YYYY-mm-ddTHH:MM:SSZ”]
- A list of date-time ranges can be provided for multiple intervals.
Optional[int]
default:"None"
The maximum number of STAC API results to return. Supported
single-collection bbox/datetime searches follow pystac-client semantics and
trust the API’s matching behavior. Multiple bboxes are queried independently,
unioned, and deduplicated before the final result limit; extended Spark-side
filters are applied before that limit. Example: 100
bool
default:"True"
If True, return the result as a Spark DataFrame instead of an iterator of PyStacItem objects.
Example: True
Returns
Union[Iterator, DataFrame]
An iterator of PyStacItem objects or a Spark DataFrame that match the specified filters.
with_basic_auth()
Parameters
str
required
The username for authentication. For API keys, this is typically the API key itself.
str
required
The password for authentication. For API keys, this is often left empty.
Returns
Self for method chaining.Example usage:
Standard basic auth
client = Client.open(“https://example.com/stac/v1”) client.with_basic_auth(“user”, “pass”)API key as username (common pattern)
client.with_basic_auth(“api_key_xyz”, "")Method chaining
df = Client.open(url).with_basic_auth(api_key, "").search(collection_id=“test”)with_bearer_token()
Parameters
str
required
The bearer token for authentication.
Returns
Self for method chaining.Example usage:
Bearer token auth
client = Client.open(“https://example.com/stac/v1”) client.with_bearer_token(“your_access_token_here”)Method chaining
df = Client.open(url).with_bearer_token(token).search(collection_id=“test”)CollectionClient
Import fromsedona.spark.stac.collection_client.
Parameters
str
required
The base URL of the STAC API.
Optional[str]
default:"None"
The ID of the collection to access. If None, accesses the catalog root.
Optional[dict]
default:"None"
Optional dictionary of HTTP headers for authentication.
get_dataframe()
Parameters
Union[str, list]
A variable number of item IDs to filter the items.
Example: “item_id1” or [“item_id1”, “item_id2”]
Optional[list]
default:"None"
A list of bounding boxes for filtering the items.
Each bounding box is represented as a list of four float values: [min_lon, min_lat, max_lon, max_lat].
Example: [[-180.0, -90.0, 180.0, 90.0]] # This bounding box covers the entire world.
Optional[Union[str, BaseGeometry, List[Union[str, BaseGeometry]]]]
default:"None"
Shapely geometry object(s) or WKT string(s) for spatial filtering.
Can be a single geometry, WKT string, or a list of geometries/WKT strings.
If both bbox and geometry are provided, geometry takes precedence.
Example: Polygon(…) or “POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))” or [Polygon(…), Polygon(…)]
Optional[Union[str, python_datetime.datetime, list]]
default:"None"
A single datetime, RFC 3339-compliant timestamp,
or a list of date-time ranges for filtering the items.
Example: “2020-01-01T00:00:00Z” or python_datetime.datetime(2020, 1, 1) or [[“2020-01-01T00:00:00Z”, “2021-01-01T00:00:00Z”]]
Optional[int]
default:"None"
The maximum number of STAC API results to return. Supported
single-collection bbox/datetime searches follow pystac-client semantics and
trust the API’s matching behavior. Multiple bboxes are queried independently,
unioned, and deduplicated before the final result limit; extended Spark-side
filters are applied before that limit.
Returns
DataFrame
A Spark DataFrame containing the filtered items. If no filters are provided,
the DataFrame contains all items in the collection.
Raises
RuntimeError: If there is an error loading the data or applying the filters, a RuntimeError is raised with a message indicating the failure.
get_items()
Parameters
Union[str, list]
A list of item IDs to filter the items. If not provided, no ID filtering is applied.
Optional[list]
default:"None"
A list of bounding boxes for filtering the items.
Optional[Union[str, BaseGeometry, List[Union[str, BaseGeometry]]]]
default:"None"
Shapely geometry object(s) or WKT string(s) for spatial filtering.
Can be a single geometry, WKT string, or a list of geometries/WKT strings.
If both bbox and geometry are provided, geometry takes precedence.
Optional[Union[str, python_datetime.datetime, list]]
default:"None"
A single datetime, RFC 3339-compliant timestamp,
or a list of date-time ranges for filtering the items.
Optional[int]
default:"None"
The maximum number of STAC API results to return. Supported
single-collection bbox/datetime searches follow pystac-client semantics and
trust the API’s matching behavior. Multiple bboxes are queried independently,
unioned, and deduplicated before the final result limit; extended Spark-side
filters are applied before that limit.
Returns
Iterator
An iterator of PyStacItem objects that match the specified filters.
If no filters are provided, the iterator contains all items in the collection.
Raises
RuntimeError: If there is an error loading the data or applying the filters, a RuntimeError is raised with a message indicating the failure.
load_items_df()
Parameters
required
required
required
required
required
save_to_geoparquet()
Parameters
Union[str, list]
A list of item IDs to filter the items. If not provided, no ID filtering is applied.
str
required
The path where the Parquet file will be saved.
Optional[list]
default:"None"
A bounding box for filtering the items. If not provided, no spatial filtering is applied.
Optional[Union[str, BaseGeometry, List[Union[str, BaseGeometry]]]]
default:"None"
Shapely geometry object(s) or WKT string(s) for spatial filtering.
If both bbox and geometry are provided, geometry takes precedence.
Optional[list]
default:"None"
A temporal extent that defines the
date-time range for filtering the items. If not provided, no temporal filtering is applied.
To match a single datetime, you can set the start and end datetime to the same value in the datetime.
Example: [[“2020-01-01T00:00:00Z”, “2020-01-01T00:00:00Z”]]
Raises
RuntimeError: If there is an error loading the data, applying the filters, or saving the DataFrame to Parquet format, a RuntimeError is raised with a message indicating the failure.
get_collection_url
Import fromsedona.spark.stac.collection_client.
Parameters
str
required
The base URL of the STAC collection.
Optional[str]
default:"None"
The optional collection ID to append to the URL.
Returns
str
The constructed collection URL.
Raises
ValueError: If the URL does not start with ‘http’ or ‘https’ and a collection ID is provided.

