Пример #1
0
def test_compute_some_features():
    input_path = data_dir / "test_0.02_seconde.las"
    xyz = las_utils.read_las_xyz(input_path)
    n_points = xyz.shape[0]
    all_features = extension.compute_features(xyz, 0.15)

    for name in FEATURE_NAMES:
        features = extension.compute_features(xyz, 0.15, feature_names=[name])
        index = FEATURE_NAMES.index(name)

        assert features.shape == (n_points, 1)
        assert np.allclose(all_features[:, index], features.reshape(-1), equal_nan=True)
Пример #2
0
def test_write_extra_dims(tmp_path):
    input_path = data_dir / "test_0.02_seconde.las"
    output_path = tmp_path / "test_output.las"

    xyz = las_utils.read_las_xyz(input_path)

    features = extension.compute_features(xyz, 0.15)

    las_utils.write_with_extra_dims(input_path, output_path, features, FEATURE_NAMES)

    output_features = []
    with laspy.file.File(output_path, mode="r") as las:
        xyz_out = np.stack([las.x, las.y, las.z], axis=1)
        for spec in las.reader.extra_dimensions:
            name = spec.name.replace(b"\x00", b"").decode()
            output_features.append(getattr(las, name))

        output_features = np.vstack(output_features).T

    assert np.allclose(xyz, xyz_out)
    assert np.allclose(features, output_features, equal_nan=True)
Пример #3
0
def test_write_extra_dims(tmp_path):
    input_path = data_dir / "test_0.02_seconde.las"
    output_path = tmp_path / "test_output.las"

    xyz = las_utils.read_las_xyz(input_path)

    features = extension.compute_features(xyz, 0.15)

    las_utils.write_with_extra_dims(input_path, output_path, features,
                                    FEATURE_NAMES)

    output_features = []
    with laspy.open(output_path, mode="r") as las:
        las_data = las.read()
        xyz_out = las_data.xyz
        for spec in las.header.point_format.extra_dimensions:
            name = spec.name.encode().replace(b"\x00", b"").decode()
            output_features.append(getattr(las_data, name))

        output_features = np.vstack(output_features).T

    assert np.allclose(xyz, xyz_out)
    assert np.allclose(features, output_features, equal_nan=True)
Пример #4
0
def test_read_las_offset():
    input_file = TEST_DATA / "test_0.02_seconde.las"
    xyz, offset = las_utils.read_las_xyz(input_file, with_offset=True)
    assert xyz.shape == (10310, 3)
    assert xyz.dtype == np.float32
    assert offset == [362327.0, 5157620.0, 106.271]
Пример #5
0
def test_read_las():
    input_file = TEST_DATA / "test_0.02_seconde.las"
    xyz = las_utils.read_las_xyz(input_file)
    assert xyz.shape == (10310, 3)
    assert xyz.dtype == np.float64