Ejemplo n.º 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)
Ejemplo n.º 2
0
def test_compute_features():
    n_points = 1000
    points = np.random.random((n_points, 3)) * 10

    features = extension.compute_features(points, 0.15)

    assert features.shape == (n_points, 14)
Ejemplo n.º 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.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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
def test_wrong_shape():
    points = np.random.random((3, 1000))

    with pytest.raises(ValueError):
        extension.compute_features(points, 0.15)