def test_write_extra_dimensions_gps_time(data): data["new_stuff"] = (np.random.random(100) * 100).astype("u1") jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.new_stuff, data["new_stuff"]) assert np.allclose(f.gps_time, data["gps_time"]) assert f.new_stuff.dtype == np.dtype("u1")
def test_write_simple(data): jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["x"], atol=0.0001) assert np.allclose(f.y, data["y"], atol=0.0001) assert np.allclose(f.z, data["z"], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_simple_laz(data): jaklas.write(data, TEMP_OUTPUT_LAZ) f = pylas.read(str(TEMP_OUTPUT_LAZ)) assert f.header.are_points_compressed assert np.allclose(f.x, data["x"], atol=0.0001) assert np.allclose(f.y, data["y"], atol=0.0001) assert np.allclose(f.z, data["z"], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_crs(): jaklas.write(point_data_gps_time, TEMP_OUTPUT, crs=2950) f = pylas.read(str(TEMP_OUTPUT)) # note: there is a bug in pylas (to be fixed) # where WktCoordinateSystemVlr is read as WktMathTransformVlr # wkt = f.vlrs.get("WktCoordinateSystemVlr")[0].string wkt = f.vlrs[0].string expected_wkt = pyproj.CRS.from_epsg(2950).to_wkt() assert expected_wkt == wkt[:-1] # null-terminated string in las file
def test_write_offset(data): xyz_offset = (1, 2, 3) jaklas.write(data, TEMP_OUTPUT, xyz_offset=xyz_offset) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["x"] + xyz_offset[0], atol=0.0001) assert np.allclose(f.y, data["y"] + xyz_offset[1], atol=0.0001) assert np.allclose(f.z, data["z"] + xyz_offset[2], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_large_classifications(): data = point_data_large_classification jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert f.point_format.id == 6 assert np.allclose(f.x, data["x"], atol=0.0001) assert np.allclose(f.y, data["y"], atol=0.0001) assert np.allclose(f.z, data["z"], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_large_coordinates(data): data = deepcopy(data) data["x"] += 320000 data["y"] += 5000000 data["z"] -= 20 jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["x"], atol=0.0001) assert np.allclose(f.y, data["y"], atol=0.0001) assert np.allclose(f.z, data["z"], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_xyz(data): data = deepcopy(data) data["xyz"] = np.vstack([data["x"], data["y"], data["z"]]).T del data["x"] del data["y"] del data["z"] jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["xyz"][:, 0], atol=0.0001) assert np.allclose(f.y, data["xyz"][:, 1], atol=0.0001) assert np.allclose(f.z, data["xyz"][:, 2], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_large_coordinates_xyz_offset(data): data = deepcopy(data) xyz_offset = (3e5, 5e6, 100) data["x"] = data["x"].astype("f") data["y"] = data["y"].astype("f") data["z"] = data["z"].astype("f") jaklas.write(data, TEMP_OUTPUT, xyz_offset=xyz_offset) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["x"].astype("d") + xyz_offset[0], atol=0.0001) assert np.allclose(f.y, data["y"].astype("d") + xyz_offset[1], atol=0.0001) assert np.allclose(f.z, data["z"].astype("d") + xyz_offset[2], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"])
def test_write_X_Y_Z(data): data = deepcopy(data) data["X"] = data["x"] data["Y"] = data["y"] data["Z"] = data["z"] del data["x"] del data["y"] del data["z"] jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.x, data["X"], atol=0.0001) assert np.allclose(f.y, data["Y"], atol=0.0001) assert np.allclose(f.z, data["Z"], atol=0.0001) assert np.allclose(f.intensity, data["intensity"].astype("u2")) assert np.allclose(f.classification, data["classification"]) assert np.allclose(f.gps_time, data["gps_time"])
def test_write_scaled(): data = point_data_color data_min_max = { "intensity": (0, 255), "red": (0, 255), "green": (0, 255), "blue": (0, 255), } def u1_to_u2(data): return data * (2 ** 8 + 1) jaklas.write(data, TEMP_OUTPUT, data_min_max=data_min_max) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.intensity, u1_to_u2(data["intensity"]).astype("u2")) assert np.allclose(f.red, u1_to_u2(data["red"]).astype("u2")) assert np.allclose(f.green, u1_to_u2(data["green"]).astype("u2")) assert np.allclose(f.blue, u1_to_u2(data["blue"]).astype("u2"))
def test_read_all_fields(): data = read(very_small_las) out = TEMP_DIR / "out.las" data["something_else"] = np.full(len(data["xyz"]), fill_value=1) write(data, out) data_out = read(out) assert sorted(list(data_out)) == [ "classification", "edge_of_flight_line", "gps_time", "intensity", "key_point", "number_of_returns", "point_source_id", "return_number", "scan_angle_rank", "scan_direction_flag", "something_else", "synthetic", "user_data", "withheld", "xyz", ]
def test_write_color(data): jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.red, data["red"].astype("u2")) assert np.allclose(f.green, data["green"].astype("u2")) assert np.allclose(f.blue, data["blue"].astype("u2"))
def test_write_gps_time(data): jaklas.write(data, TEMP_OUTPUT) f = pylas.read(str(TEMP_OUTPUT)) assert np.allclose(f.gps_time, data["gps_time"], atol=0.0001)