Skip to content

Example script to read ALOS2 data

Requires additional dependencies

python3 -m pip install matplotlib scikit-image

plot_patches

plot_patches(rootdir)

Loads a ALOS-2 dataset and display some extracted patches

Source code in examples/read_alos2.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
def plot_patches(rootdir):
    """
    Loads a ALOS-2 dataset and display some extracted patches
    """
    # Get and find a VOL file in the provided path
    vol_filepath = get_volfile(rootdir)

    # Limit to a subpart of the ALOS-2 data
    # This corresponds to the annotated region of the PolSF dataset
    crop_coordinates = ((2832, 736), (7888, 3520))
    dataset = alos2.ALOSDataset(
        vol_filepath,
        patch_size=(512, 512),
        patch_stride=(128, 128),
        crop_coordinates=crop_coordinates,
    )

    # Plot consecutive samples
    fig, axes = plt.subplots(1, 4, figsize=(10, 4))
    for i, ax in enumerate(axes):
        X = dataset[i]
        X = X[:, ::-1, :]
        xi = X[0]
        norm_xi = normalize(xi)
        ax.imshow(norm_xi, cmap="gray")
        ax.set_title(f"Sample {i}")
        ax.axis("off")
    plt.tight_layout()

    # Plot the four polarizations of the same patch
    X = dataset[0]
    X = X[:, ::-1, :]
    fig, axes = plt.subplots(1, 4, figsize=(10, 4))
    for xi, ax, ax_title in zip(X, axes, ["HH", "HV", "VH", "VV"]):
        norm_xi = normalize(xi)
        ax.imshow(norm_xi, cmap="gray")
        ax.axis("off")
        ax.set_title(ax_title)
    plt.tight_layout()

    plt.show()

plot_summaries

plot_summaries(rootdir)

Loads a ALOS-2 dataset and prints some informations extracted from the Volume, Leader, Trailer and Image files

Source code in examples/read_alos2.py
70
71
72
73
74
75
76
77
78
79
80
81
82
def plot_summaries(rootdir):
    """
    Loads a ALOS-2 dataset and prints some informations extracted from the
    Volume, Leader, Trailer and Image files
    """
    # Get and find a VOL file in the provided path
    vol_filepath = get_volfile(rootdir)

    # Parse the data
    dataset = alos2.ALOSDataset(vol_filepath)

    # And print some decoded infos
    dataset.describe()