rio_stac.stac
rio_stac.stac ¶
Create STAC Item from a rasterio dataset.
_get_stats ¶
_get_stats(arr: MaskedArray, bins: Union[int, str, Sequence] = 10, range: Optional[Tuple[float, float]] = None) -> Dict
Calculate array statistics.
bbox_to_geom ¶
Return a geojson geometry from a bbox.
create_stac_item ¶
create_stac_item(source: Union[str, DatasetReader, DatasetWriter, WarpedVRT, MemoryFile], input_datetime: Optional[datetime] = None, extensions: Optional[List[str]] = None, collection: Optional[str] = None, collection_url: Optional[str] = None, properties: Optional[Dict] = None, id: Optional[str] = None, assets: Optional[Dict[str, Asset]] = None, asset_name: str = 'asset', asset_roles: Optional[List[str]] = None, asset_media_type: Optional[Union[str, MediaType]] = 'auto', asset_href: Optional[str] = None, with_proj: bool = False, with_raster: bool = False, with_eo: bool = False, raster_max_size: int = 1024, geom_densify_pts: int = 0, geom_precision: int = -1, geographic_crs: CRS = EPSG_4326, histogram_bins: Union[int, str, Sequence] = 10, histogram_range: Optional[Tuple[float, float]] = None) -> Item
Create a Stac Item.
Parameters:
-
source
(str or opened rasterio dataset
) –input path or rasterio dataset.
-
input_datetime
(datetime
, default:None
) –datetime associated with the item.
-
extensions
(list of str
, default:None
) –input list of extensions to use in the item.
-
collection
(str
, default:None
) –name of collection the item belongs to.
-
collection_url
(str
, default:None
) –Link to the STAC Collection.
-
properties
(dict
, default:None
) –additional properties to add in the item.
-
id
(str
, default:None
) –id to assign to the item (default to the source basename).
-
assets
(dict
, default:None
) –Assets to set in the item. If set we won't create one from the source.
-
asset_name
(str
, default:'asset'
) –asset name in the Assets object.
-
asset_roles
(list of str
, default:None
) –list of str | list of asset's roles.
-
asset_media_type
(str or MediaType
, default:'auto'
) –asset's media type.
-
asset_href
(str
, default:None
) –asset's URI (default to input path).
-
with_proj
(bool
, default:False
) –Add the
projection
extension and properties (default to False). -
with_raster
(bool
, default:False
) –Add the
raster
extension and properties (default to False). -
with_eo
(bool
, default:False
) –Add the
eo
extension and properties (default to False). -
raster_max_size
(int
, default:1024
) –Limit array size from which to get the raster statistics. Defaults to 1024.
-
geom_densify_pts
(int
, default:0
) –Number of points to add to each edge to account for nonlinear edges transformation (Note: GDAL uses 21).
-
geom_precision
(int
, default:-1
) –If >= 0, geometry coordinates will be rounded to this number of decimal.
Returns:
-
Item
–pystac.Item: valid STAC Item.
get_dataset_geom ¶
get_dataset_geom(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT, MemoryFile], densify_pts: int = 0, precision: int = -1, geographic_crs: CRS = EPSG_4326) -> Dict
Get Raster Footprint.
get_eobands_info ¶
get_eobands_info(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT, MemoryFile]) -> List
Get eo:bands metadata.
get_media_type ¶
get_media_type(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT, MemoryFile]) -> Optional[MediaType]
Find MediaType for a raster dataset.
get_projection_info ¶
get_projection_info(src_dst: Union[DatasetReader, DatasetWriter, WarpedVRT, MemoryFile]) -> Dict
Get projection metadata.
The STAC projection extension allows for three different ways to describe the coordinate reference system associated with a raster : - EPSG code - WKT2 - PROJJSON
All are optional, and they can be provided altogether as well. Therefore, as long as one can be obtained from the data, we add it to the returned dictionary.