Generator
CollectionGenerator
CollectionGenerator class. User should not need to subclass this class unless greater control over how collection is generated from items is needed.
__init__(collection_config, generators, pool=None)
Constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection_config
|
StacCollectionConfig
|
collection metadata as a |
required |
generators
|
Sequence[ItemGenerator[T]]
|
sequence of |
required |
pool
|
Executor | None
|
Executor pool for parallel processing. Defaults to None. |
None
|
check_duplicated_id()
Validates that the items have unique id within this collection
spatial_extent(items)
staticmethod
Extract a collection's spatial extent based on geometry information of its items.
Produces the smallest bounding box that encloses all items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
Sequence[pystac.Item]
|
sequence of generated items |
required |
Returns:
| Type | Description |
|---|---|
pystac.SpatialExtent
|
pystac.SpatialExtent: the calculated spatial extent object |
temporal_extent(items)
staticmethod
Extract a collection's temporal extent based on time information of its items.
Produces the tuple (start_ts, end_ts) which are the smallest and largest timestamps of the Items' start_datetime and end_datetime values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
Sequence[pystac.Item]
|
sequence of generated items |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
if an item's datetime attribute cannot be accessed |
Returns:
| Type | Description |
|---|---|
pystac.TemporalExtent
|
pystac.TemporalExtent: the calculated [start_ts, end_ts] object. |
__call__()
Generate all items from ItemGenerator then generate the Collection object
ItemGenerator
Bases: abc.ABC, Generic[T]
Base ItemGenerator object. Users should extend this class for handling different file extensions.
source_type
instance-attribute
SourceConfig subclass that contains information used for parsing the source file
__init__(config)
Base ItemGenerator object. Users should extend this class for handling different file extensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
dict[str, Any] | T
|
source data configs - either from csv config or yaml/json |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
if an invalid config is provided |
generate()
abstractmethod
Abstract method that handles pystac.Item generation from the appropriate config
BaseVectorGenerator
Bases: ItemGenerator[T]
Base Generator Object for handling vector and point assets
geometry(df)
staticmethod
Calculate the geometry from geopandas dataframe.
If geopandas dataframe has only one item, the geometry will be that of the item. If geopandas dataframe has less than 10 items of the same type, the geometry will be the Multi version of the type. Note that MultiPoint will be unpacked into points for the 10 items limit. If there are more than 10 items of the same type or there are items of different types i.e. Point and LineString, the returned geometry will be the Polygon of the bounding box. Note that Point and MultiPoint are treated as the same type (so are type and its Multi version).
Returns:
| Name | Type | Description |
|---|---|---|
Geometry |
Geometry
|
extracted geometry |
df_to_item(df, assets, source_config, properties, epsg=4326, time_column=None)
staticmethod
Convert dataframe to pystac.Item
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
gpd.GeoDataFrame
|
input dataframe |
required |
assets
|
dict[str, pystac.Asset]
|
data asset object |
required |
source_config
|
SourceConfig
|
config object |
required |
properties
|
dict[str, Any]
|
serialised properties |
required |
epsg
|
int
|
frame's epsg code. Defaults to 4326. |
4326
|
time_column
|
str | None
|
datetime column in the dataframe. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
pystac.Item
|
pystac.Item: generated STAC Item |
StacSerialiser
Class that handles validating generated stac metadata and storing them locally or remotely
__init__(generator, href)
Constructor
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
generator
|
CollectionGenerator
|
collection generator object |
required |
href
|
str | Path
|
serialisation location |
required |
pre_serialisation_hook(collection, href)
Hook that can be overwritten to provide pre-serialisation functionality. By default, this normalises collection href and performs validation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
collection
|
pystac.Collection
|
stac Collection |
required |
href
|
str
|
href for normalisation |
required |
__call__()
Call API for serialisation
prepare_collection_configs(collection_generator)
staticmethod
Convert the configs of all items in the collection to a list of python dictionaries
prepare_config(config)
staticmethod
Convert config object to python dictionary
save_collection_config(dst)
Convenient API for writing all the config of all items in the collection to a dst
save_configs(configs, dst)
staticmethod
Convenient API for writing a sequence of config objects to dst
to_json()
Generate STAC Collection and save to disk as json files
to_api()
_Generate STAC Collection and push to remote API. The API will first attempt to send a POST request which will be replaced with a PUT request if a 409 error is encountered
PointGenerator
Bases: BaseVectorGenerator[PointConfig]
ItemGenerator class that handles point data in csv format
generate()
Generate a STAC Item based on provided point config
Returns:
| Type | Description |
|---|---|
pystac.Item
|
pystac.Item: generated STAC Item |
VectorGenerator
Bases: BaseVectorGenerator[VectorConfig]
ItemGenerator class that handles vector data with common vector formats - i.e (shp, zipped shp, gpkg, geojson)
generate()
Create a STAC Item from a VectorConfig
Raises:
| Type | Description |
|---|---|
StacConfigException
|
if the stac config fails a validation check |
Returns:
| Type | Description |
|---|---|
pystac.Item
|
pystac.Item: generated STAC Item |
RasterGenerator
Bases: ItemGenerator[RasterConfig]
Raster Generator
generate()
Generate a STAC Item from RasterConfig
Raises:
| Type | Description |
|---|---|
SourceAssetException
|
if the data cannot be accessed |
Returns:
| Type | Description |
|---|---|
pystac.Item
|
pystac.Item: generated STAC Item |