dep_tools.landsat_utils module

dep_tools.landsat_utils.cloud_mask(xr, filters=None)[source]

Get the cloud mask for landsat data.

Parameters:
  • xr (DataArray | Dataset) – An xarray object containing Landsat data, including the qa_pixel band.

  • filters (Optional[Iterable[Tuple[str, int]]]) – List of filters to apply to the cloud mask. Each filter is a tuple of (<filter name>, <filter size>). Valid filter names are ‘opening’ and ‘dilation’. If None, no filters will be applied. For example: [(“closing”, 10),(“opening”, 2),(“dilation”, 2)].

Return type:

DataArray | Dataset

Returns:

The cloud mask defined by the ‘qa_pixel’ band, with optional filters applied.

dep_tools.landsat_utils.mask_clouds(xr, filters=None, keep_ints=False)[source]

Mask clouds in Landsat data.

Parameters:
  • xr (DataArray | Dataset) – DataArray containing Landsat data including the qa_pixel band.

  • filters (Optional[Iterable[Tuple[str, int]]]) – List of filters to apply to the cloud mask. Each filter is a tuple of (<filter name>, <filter size>). Valid filter names are ‘opening’ and ‘dilation’. If None, no filters will be applied. For example: [(“closing”, 10),(“opening”, 2),(“dilation”, 2)].

  • keep_ints (bool) – If True, return the masked data as integers. Otherwise, return the masked data as floats.

Return type:

DataArray | Dataset

Returns:

The input, with masks applied.

dep_tools.landsat_utils.landsat_grid()[source]

The official Landsat grid filtered to Pacific Island Countries and Territories as defined by GADM.

Return type:

GeoDataFrame

Returns:

A GeoDataFrame, indexed by ‘PATH’ & ‘ROW’.

dep_tools.landsat_utils.read_pathrows_file()[source]

Read list of pathrows containing land within the Digital Earth Pacific aoi from a file and return them as a list of tuples.

Return type:

list[Tuple[int, ...]]

Returns:

A list of tuples of the form (<path>, <row>).

dep_tools.landsat_utils.pathrows_in_area(area, pathrows=None)[source]

Get a list of Landsat pathrows in a given area or areas.

Parameters:
  • area (GeoDataFrame) – A geopandas.GeoDataFrame with polygons.

  • pathrows (Optional[GeoDataFrame]) – The pathrows. If unset, the Landsat pathrows are downloaded and used.

Return type:

GeoDataFrame

Returns:

A geopandas.GeoDataFrame of pathrows that intersect the given area.

dep_tools.landsat_utils.items_in_pathrows(items, some_pathrows)[source]

Filter STAC items to a set of Landsat pathrows.

This function is likely due for deprecation.

Parameters:
  • items (ItemCollection) – A pystac.ItemCollection. The Landsat pathrow of each item is identified by the properties ‘landsat:wrs_path’ and ‘landsat:wrs_row’.

  • some_pathrows (GeoDataFrame) – The Landsat pathrows of interest. The columns ‘PATH’ and ‘ROW’, containing integer or string values are used to identify the pathrows.

Return type:

ItemCollection

Returns:

The filtered pathrows.

dep_tools.landsat_utils.pathrow_with_greatest_area(shapes)[source]

Return the Landsat pathrow with the largest intersection of the given shapes.

Parameters:

shapes (GeoDataFrame) – A geopandas.GeoDataFrame with polygons or multipolygons.

Return type:

Tuple[str, str]

Returns:

A tuple of the form (<path>, <row>), indicating the Landsat pathrow with the greatest overlap.