def load_collection(cls, collection_id: str, session: 'Connection' = None, spatial_extent: Union[Dict[str, float], None] = None, temporal_extent: Union[List[Union[str, datetime.datetime, datetime.date]], None] = None, bands: Union[List[str], None] = None, fetch_metadata=True): """ Create a new Image Collection/Raster Data cube. :param collection_id: A collection id, should exist in the backend. :param session: The session to use to connect with the backend. :param spatial_extent: limit data to specified bounding box or polygons :param temporal_extent: limit data to specified temporal interval :param bands: only add the specified bands :return: """ # TODO: rename function to load_collection for better similarity with corresponding process id? builder = GraphBuilder() process_id = 'load_collection' normalized_temporal_extent = list( get_temporal_extent(extent=temporal_extent) ) if temporal_extent is not None else None arguments = { 'id': collection_id, 'spatial_extent': spatial_extent, 'temporal_extent': normalized_temporal_extent, } metadata = session.collection_metadata( collection_id) if fetch_metadata else None if bands: if isinstance(bands, str): bands = [bands] if metadata: bands = [ metadata.band_dimension.band_name(b, allow_common=False) for b in bands ] arguments['bands'] = bands node_id = builder.process(process_id, arguments) if bands: metadata = metadata.filter_bands(bands) return cls(node_id, builder, session, metadata=metadata)
def load_disk_collection(cls, session: 'Connection', file_format: str, glob_pattern: str, **options) -> 'ImageCollection': """ Loads image data from disk as an ImageCollection. :param session: The session to use to connect with the backend. :param file_format: the file format, e.g. 'GTiff' :param glob_pattern: a glob pattern that matches the files to load from disk :param options: options specific to the file format :return: the data as an ImageCollection """ builder = GraphBuilder() process_id = 'load_disk_data' arguments = { 'format': file_format, 'glob_pattern': glob_pattern, 'options': options } node_id = builder.process(process_id, arguments) return cls(node_id, builder, session, metadata={})
def test_create_empty(self): builder = GraphBuilder() builder.process("sum", {}) self.assertEqual(1, len(builder.processes))