mapchete_eo.search package
Submodules
mapchete_eo.search.base module
- class mapchete_eo.search.base.CollectionSearcher(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
ABCBridge between a Source and a catalog implementation.
- property config: BaseModel
- class mapchete_eo.search.base.FSSpecStacIO(headers: dict[str, str] | None = None, conformance: list[str] | None = None, parameters: dict[str, Any] | None = None, request_modifier: Callable[[Request], Request | None] | None = None, timeout: float | tuple[float, float] | tuple[float, None] | None = None, max_retries: int | Retry | None = 5)[source]
Bases:
StacApiIOCustom class which allows I/O operations on object storage.
- read_text(source: str | PathLike, *args, **kwargs) str[source]
Read text from the given URI.
Overwrites the default method for reading text from a URL or file to allow
urllib.request.Requestinstances as input. This method also raises anyurllib.error.HTTPErrorexceptions rather than catching them to allow us to handle different response status codes as needed.
- static save_json(dest: str | PathLike, json_dict: dict, *args, **kwargs) None[source]
Write a dict to the given URI as JSON.
See
StacIO.write_textfor usage of str vs Link as a parameter.- Parameters:
dest – The destination file to write the text to.
json_dict – The JSON dict to write.
*args – Additional positional arguments to be passed to
StacIO.json_dumps().**kwargs – Additional keyword arguments to be passed to
StacIO.json_dumps().
- class mapchete_eo.search.base.StaticCollectionWriterMixin(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
CollectionSearcher- write_static_catalog(output_path: str | ~os.PathLike, bounds: ~mapchete.types.Bounds | None = None, area: ~shapely.geometry.base.BaseGeometry | None = None, time: ~mapchete_eo.types.TimeRange | None = None, search_kwargs: ~typing.Dict[str, ~typing.Any] | None = None, name: str | None = None, description: str | None = None, assets: ~typing.List[str] | None = None, assets_dst_resolution: None | float | int = None, assets_convert_profile: ~rasterio.profiles.Profile | None = None, copy_metadata: bool = False, metadata_parser_classes: tuple | None = None, overwrite: bool = False, stac_io: ~pystac.stac_io.DefaultStacIO = <mapchete_eo.search.base.FSSpecStacIO object>, progress_callback: ~typing.Callable | None = None) MPath[source]
Export a static STAC catalog from the search results.
- Parameters:
output_path – Destination directory for the static catalog.
bounds – Spatial filter bounds.
area – Spatial filter geometry.
time – Temporal filter range.
search_kwargs – Additional search arguments.
name – Catalog name.
description – Catalog description.
assets – List of assets to download.
assets_dst_resolution – Sub-sampling resolution for assets.
assets_convert_profile – Output profile for assets (e.g. for COG conversion).
copy_metadata – Whether to copy sidecar metadata files.
metadata_parser_classes – Custom parser classes for metadata.
overwrite – Overwrite existing files.
stac_io – Custom STAC IO implementation.
progress_callback – Optional function for progress reporting.
- Returns:
Path to the generated catalog.json.
- Return type:
MPath
- mapchete_eo.search.base.filter_items(items: Generator[Item, None, None], query: str | None = None) Generator[Item, None, None][source]
Only for cloudcover now, this can and should be adapted for filter field and value the field and value for the item filter would be defined in search.config.py corresponding configs and passed down to the individual search approaches via said config and this Function.
mapchete_eo.search.config module
- class mapchete_eo.search.config.StacSearchConfig(*, max_cloud_cover: float = 100.0, query: str | None = None, catalog_chunk_threshold: int = 10000, catalog_chunk_zoom: int = 5, catalog_pagesize: int = 100, footprint_buffer: float = 0)[source]
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class mapchete_eo.search.config.StacStaticConfig[source]
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class mapchete_eo.search.config.UTMSearchConfig(*, sinergise_aws_collections: dict = {'S1_GRD': {'endpoint': 's3://sentinel-s1-l1c-stac', 'id': 'sentinel-s1-l1c', 'path': <mapchete.io.MPath object: https://sentinel-s1-l1c-stac.s3.amazonaws.com/sentinel-s1-l1c.json, storage_options={'asynchronous': False, 'timeout': None}>}, 'S2_L1C': {'endpoint': 's3://sentinel-s2-l1c-stac', 'id': 'sentinel-s2-l1c', 'path': <mapchete.io.MPath object: https://sentinel-s2-l1c-stac.s3.amazonaws.com/sentinel-s2-l1c.json, storage_options={'asynchronous': False, 'timeout': None}>}, 'S2_L2A': {'endpoint': 's3://sentinel-s2-l2a-stac', 'id': 'sentinel-s2-l2a', 'path': <mapchete.io.MPath object: https://sentinel-s2-l2a-stac.s3.amazonaws.com/sentinel-s2-l2a.json, storage_options={'asynchronous': False, 'timeout': None}>}}, search_index: str | ~os.PathLike | None = None)[source]
Bases:
BaseModel- model_config: ClassVar[ConfigDict] = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
mapchete_eo.search.s2_mgrs module
- exception mapchete_eo.search.s2_mgrs.InvalidMGRSSquare[source]
Bases:
ExceptionRaised when an invalid square index has been given
- class mapchete_eo.search.s2_mgrs.MGRSCell(utm_zone: 'str', latitude_band: 'str')[source]
Bases:
object
mapchete_eo.search.stac_search module
- class mapchete_eo.search.stac_search.STACSearchCollection(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for STAC APIs.
- config_cls
alias of
StacSearchConfig
- class mapchete_eo.search.stac_search.SpatialSearchChunks(bounds: List[float] | Tuple[float, float, float, float] | dict | Polygon | None = None, area: BaseGeometry | None = None, zoom: int = 6, grid: str = 'geodetic')[source]
Bases:
objectSplit spatial search areas into smaller chunks for large queries.
- area: BaseGeometry
- bounds: Bounds
- tile_pyramid: BufferedTilePyramid
mapchete_eo.search.stac_static module
- class mapchete_eo.search.stac_static.STACStaticCollection(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for static STAC collections.
- config_cls
alias of
StacStaticConfig
mapchete_eo.search.utm_search module
- class mapchete_eo.search.utm_search.UTMSearchCatalog(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for UTM-grid based catalogs (e.g. Sentinel-2 on AWS).
- config_cls
alias of
UTMSearchConfig
- get_collections()[source]
- yeild transformed collection from:
https://sentinel-s2-l2a-stac.s3.amazonaws.com/sentinel-s2-l2a.json, or https://sentinel-s2-l1c-stac.s3.amazonaws.com/sentinel-s2-l1c.json, etc.
- mapchete_eo.search.utm_search.find_items(path: MPath, s2_tiles: List[S2Tile], product_endswith: str = 'T{tile_id}.json') Generator[Item, None, None][source]
Module contents
A catalog is an instance with a specific endpoint and a specific collection.
The catalog class aims to abstract product search as well as homogenization of product metadata.
It helps the InputData class to find the input products and their metadata.
- class mapchete_eo.search.STACSearchCollection(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for STAC APIs.
- config_cls
alias of
StacSearchConfig
- class mapchete_eo.search.STACStaticCollection(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for static STAC collections.
- config_cls
alias of
StacStaticConfig
- class mapchete_eo.search.UTMSearchCatalog(collection: str, stac_item_modifiers: List[Callable[[Item], Item]] | None = None)[source]
Bases:
StaticCollectionWriterMixin,CollectionSearcherSearch implementation for UTM-grid based catalogs (e.g. Sentinel-2 on AWS).
- config_cls
alias of
UTMSearchConfig
- get_collections()[source]
- yeild transformed collection from:
https://sentinel-s2-l2a-stac.s3.amazonaws.com/sentinel-s2-l2a.json, or https://sentinel-s2-l1c-stac.s3.amazonaws.com/sentinel-s2-l1c.json, etc.