pycontrails.datalib.landsat¶
Support for LANDSAT 8-9 imagery retrieval through Google Cloud Platform.
Module Attributes
BigQuery table with imagery metadata |
|
Default columns to include in queries |
|
Default spatial extent for queries |
|
Extra filters for BigQuery queries |
|
Default Landsat channels to use if none are specified. |
|
Strip this prefix from GCP URLs when caching Landsat files locally |
Functions
|
Extract artifacts for visualizing Landsat data with the given color scheme. |
|
Find Landsat 8 and 9 imagery intersecting with flight track. |
|
Find Landsat 8 and 9 imagery within spatiotemporal region of interest. |
Compute 3d RGB array for the Google contrails color scheme. |
|
|
Compute 3d RGB array for the true color scheme. |
Classes
|
Support for Landsat 8 and 9 data handling. |
- pycontrails.datalib.landsat.BQ_DEFAULT_COLUMNS = ['base_url', 'sensing_time']¶
Default columns to include in queries
- pycontrails.datalib.landsat.BQ_DEFAULT_EXTENT = '{"type": "Polygon", "coordinates": [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]}'¶
Default spatial extent for queries
- pycontrails.datalib.landsat.BQ_EXTRA_FILTERS = 'AND spacecraft_id in ("LANDSAT_8", "LANDSAT_9")'¶
Extra filters for BigQuery queries
- pycontrails.datalib.landsat.BQ_TABLE = 'bigquery-public-data.cloud_storage_geo_index.landsat_index'¶
BigQuery table with imagery metadata
- pycontrails.datalib.landsat.DEFAULT_BANDS = ['B2', 'B3', 'B4']¶
Default Landsat channels to use if none are specified. These are visible bands for producing a true color composite.
- pycontrails.datalib.landsat.GCP_STRIP_PREFIX = 'gs://gcp-public-data-landsat/'¶
Strip this prefix from GCP URLs when caching Landsat files locally
- class pycontrails.datalib.landsat.Landsat(base_url, bands=None, cachestore=None)¶
Bases:
object
Support for Landsat 8 and 9 data handling.
This class uses the PROJ coordinate transformation software through the pyproj python interface. pyproj is installed as part of the
sat
set of optional dependencies (pip install pycontrails[sat]
), but PROJ must be installed manually.- Parameters:
base_url (
str
) – Base URL of Landsat scene. To find URLs for Landsat scenes at specific locations and times, seequery()
andintersect()
.bands (
str | set[str] | None
) – Set of bands to retrieve. The 11 possible bands are represented by the string “B1” to “B11”. For the Google Landsat contrails color scheme, setbands=("B9", "B10", "B11")
. For the true color scheme, setbands=("B2", "B3", "B4")
. By default, bands for the true color scheme are used. Bands must share a common resolution. The resolutions of each band are:B1-B7, B9: 30 m
B8: 15 m
B10, B11: 30 m (upsampled from true resolution of 100 m)
cachestore (
cache.CacheStore
, optional) – Cache store for Landsat data. If None, aDiskCacheStore
is used.
- get(reflective='reflectance', thermal='brightness_temperature')¶
Retrieve Landsat imagery.
- Parameters:
reflective (str =
{"raw", "radiance", "reflectance"}
, optional) – Whether to return raw values or rescaled radiances or reflectances for reflective bands. By default, return reflectances.thermal (str =
{"raw", "radiance", "brightness_temperature"}
, optional) – Whether to return raw values or rescaled radiances or brightness temperatures for thermal bands. By default, return brightness temperatures.
- Returns:
xarray.DataArray
– DataArray of Landsat data.
- property reflective_bands¶
List of reflective bands.
- property thermal_bands¶
List of thermal bands.
- pycontrails.datalib.landsat.extract_landsat_visualization(ds, color_scheme='true')¶
Extract artifacts for visualizing Landsat data with the given color scheme.
- Parameters:
ds (
xarray.Dataset
) – Dataset of Landsat data as returned byLandsat.get()
.color_scheme (str =
{"true", "google_contrails"}
) – Color scheme to use for visualization. The true color scheme requires reflectances for bands B2, B3, and B4; and the Google contrails color scheme requires reflectance for band B9 and brightness temperatures for bands B10 and B11.
- Returns:
rgb (
npt.NDArray[np.float32]
) – 3D RGB array of shape(height, width, 3)
.src_crs (
pyproj.CRS
) – Imagery projectionsrc_extent (
tuple[float,float,float,float]
) – Imagery extent in projected coordinates
References
- pycontrails.datalib.landsat.intersect(flight, columns=None)¶
Find Landsat 8 and 9 imagery intersecting with flight track.
This function will return all scenes with a bounding box that includes flight waypoints both before and after the sensing time.
This function requires access to the Google BigQuery API and uses the BigQuery python library.
- Parameters:
flight (
Flight
) – Flight for intersectioncolumns (
list[str]
,optional.
) – Columns to return from Google BigQuery table. By default, returns imagery base URL and sensing time.
- Returns:
pandas.DataFrame
– Query results in pandas DataFrame
See also
search.intersect()
- pycontrails.datalib.landsat.query(start_time, end_time, extent=None, columns=None)¶
Find Landsat 8 and 9 imagery within spatiotemporal region of interest.
This function requires access to the Google BigQuery API and uses the BigQuery python library.
- Parameters:
start_time (
numpy.datetime64
) – Start of time period for searchend_time (
numpy.datetime64
) – End of time period for searchextent (
str
, optional) – Spatial region of interest as a GeoJSON string. If not provided, defaults to a global extent.columns (
list[str]
,optional.
) – Columns to return from Google BigQuery table. By default, returns imagery base URL and sensing time.
- Returns:
pandas.DataFrame
– Query results in pandas DataFrame
See also
search.query()
- pycontrails.datalib.landsat.to_google_contrails(ds)¶
Compute 3d RGB array for the Google contrails color scheme.
- Parameters:
ds (
xarray.Dataset
) – DataArray of Landsat data with reflectance for band B9 and brightness temperature for bands B10 and B11.- Returns:
numpy.ndarray
– 3d RGB array with Google landsat color scheme.src_crs (
pyproj.CRS
) – Imagery projection
References
- pycontrails.datalib.landsat.to_true_color(ds)¶
Compute 3d RGB array for the true color scheme.
- Parameters:
ds (
xarray.Dataset
) – DataArray of Landsat data with reflectances for bands B2, B3, and B4.- Returns:
numpy.ndarray
– 3d RGB array with true color scheme.src_crs (
pyproj.CRS
) – Imagery projection