Examples

Load and inspect a scene

from pyrawph.l1.l1_event import L1_event

ev = L1_event.from_path(
    product_folder="path/to/product_folder",
    scene_id=0,
    product_kind="BC",
)

ev.show_event_info()

Access spectral bands

blue = ev.get_band("BLUE")
red = ev.get_band("RED")
nir = ev.get_band("NIR")

print(blue.shape, red.shape, nir.shape)

Build RGB and NDVI

rgb = ev.rgb()
ndvi = ev.index("NDVI")

Tile a scene

tiles = ev.to_tiles(tile_size=512, overlap=64)

print(ev.get_tiles_names())
print(ev.get_tiles_info())

tile = ev.get_tile(0)
tile.show_bands(["RED", "NIR"])

Plot scene location

ev.plot_location(mode="bounds")
ev.plot_location(mode="footprint")

Export a derived product

ndvi = ev.index("NDVI")

ev.export_to_tif(
    out_path="outputs/ndvi.tif",
    arr=ndvi,
    meta=ev.get_meta(),
)

Read only selected bands

ev = L1_event.from_path(
    product_folder="path/to/product_folder",
    scene_id=0,
    product_kind="BC",
    bands=[0, 1, 2],
)

ev.show_event_info()