def test_write_sameFileTwice(self): """ Should throw an exception. """ pc = SimpleTestData.get_point_cloud() write(pc, self.test_file_path) # Catch most specific subclass of FileExistsError (3.6) and IOError (2.7). with pytest.raises(Exception): write(pc, self.test_file_path)
def test_write_loadTheSameSimpleData(self): """ Writing point cloud data and loading it afterwards should result in the same point cloud data. """ pc_in = SimpleTestData.get_point_cloud() write(pc_in, self.test_file_path) data_in = SimpleTestData.get_data() with open(self.test_file_path, 'r') as ply: data_out = read_data(ply) self.assertEqual(data_in, data_out)
def test_write_loadTheSameSimpleHeader(self): """ Writing a simple point cloud and loading it afterwards should result in the same point cloud.""" pc_in = SimpleTestData.get_point_cloud() header_in = SimpleTestData.get_header() write(pc_in, self.test_file_path) with open(self.test_file_path, 'r') as ply: header_out = read_header(ply) self.assertMultiLineEqual(header_in, header_out)
neighbors = compute_neighborhoods(pc, target, Cell(np.float(args.radius))) iteration = 0 target_idx_base = 0 for x in neighbors: end = time.time() difftime = end - start print(("build kd-tree: %f sec") % (difftime)) print("Computed neighborhoods list length at iteration %d is: %d" % (iteration, len(x))) start1 = time.time() print("------ Feature calculation is started ------") compute_features(pc, x, target_idx_base, target, [ 'max_z', 'min_z', 'mean_z', 'median_z', 'std_z', 'var_z', 'coeff_var_z', 'skew_z', 'kurto_z', 'sigma_z', 'perc_20', 'perc_40', 'perc_60', 'perc_80', 'perc_90', 'pulse_penetration_ratio', 'point_density', 'eigenv_1', 'eigenv_2', 'eigenv_3' ], Cell(np.float(args.radius))) target_idx_base += len(x) end1 = time.time() difftime1 = end1 - start1 print(("feature calc: %f sec") % (difftime1)) iteration += 1 write(target, args.output) # # example usage: computefea_wtargets_cylinder.py D:/GitHub/eEcoLiDAR/develop-branch/eEcoLiDAR/ D:/GitHub/eEcoLiDAR/myPhD_escience_analysis/test_data/testdata.las D:/GitHub/eEcoLiDAR/myPhD_escience_analysis/test_data/testdata.las 2.5 D:/GitHub/eEcoLiDAR/myPhD_escience_analysis/test_data/testdata.ply #python D:/GitHub/eEcoLiDAR/myPhD_escience_analysis/test_laserchicken/release1/computefea_wtargets_cell.py D:/GitHub/eEcoLiDAR/develop-branch/eEcoLiDAR/ D:/Koma/Paper1_ReedStructure/Data/ALS/02gz2/testmetrics/tile_00003_norm2.las D:/Koma/Paper1_ReedStructure/Data/ALS/02gz2/testmetrics/tile_00003_norm_target.las 2.5 D:/Koma/Paper1_ReedStructure/Data/ALS/02gz2/testmetrics/testdata.ply #
print("------ Computing neighborhood is started ------") #compute_neighborhoods is now a generator. To get the result of a generator the user #needs to call next(compute_neighborhoods). The following shows how to get the results. # #indices_cyl=compute_neighborhoods(pc, target, Cell(np.float(args.radius))) # neighbors = compute_neighborhoods(pc, target, Cell(np.float(radius))) iteration = 0 target_idx_base = 0 for x in neighbors: print("Computed neighborhoods list length at iteration %d is: %d" % (iteration, len(x))) print("------ Feature calculation is started ------") compute_features(pc, x, target_idx_base, target, [ 'min_z', 'max_z', 'mean_z', 'median_z', 'perc_10', 'perc_30', 'perc_50', 'perc_70', 'perc_90', 'point_density', 'eigenv_1', 'eigenv_2', 'eigenv_3', 'z_entropy', 'std_z', 'var_z', 'skew_z', 'kurto_z', 'pulse_penetration_ratio', 'density_absolute_mean' ], Cell(np.float(radius))) target_idx_base += len(x) iteration += 1 write(target, filename + str(resolution) + "m_cell.ply") end1 = time.time() difftime1 = end1 - start1 print(("feature calc: %f sec") % (difftime1))
from laserchicken import read_las from laserchicken.spatial_selections import points_in_polygon_wkt from laserchicken import write_ply pc = read_las.read("D:/GitHub/eEcoLiDAR/eEcoLiDAR/testdata/AHN2.las") pc_out = points_in_polygon_wkt( pc, "POLYGON(( 243590.0 572110.0, 243640.0 572160.0, 243700.0 572110.0, 243640.0 572060.0, 243590.0 572110.0 ))" ) write_ply.write( pc, "D:/GitHub/komazsofi/myPhD_escience_analysis/test_data/testply_orig1.ply") write_ply.write( pc_out, "D:/GitHub/komazsofi/myPhD_escience_analysis/test_data/withinplygonply1.ply" )
print(("Number of points in target: %s ") % (target[point]['x']['data'].shape[0])) print("------ Computing neighborhood is started ------") #compute_neighborhoods is now a generator. To get the result of a generator the user #needs to call next(compute_neighborhoods). The following shows how to get the results. # #indices_cyl=compute_neighborhoods(pc, target, Cell(np.float(args.radius))) # neighbors = compute_neighborhoods(pc, target, Cell(np.float(radius))) iteration = 0 target_idx_base = 0 for x in neighbors: print("Computed neighborhoods list length at iteration %d is: %d" % (iteration, len(x))) print("------ Feature calculation is started ------") compute_features(pc, x, target_idx_base, target, [ 'max_z', 'min_z', 'mean_z', 'median_z', 'std_z', 'var_z', 'coeff_var_z', 'skew_z', 'kurto_z' ], Cell(np.float(radius))) target_idx_base += len(x) iteration += 1 write(target, workingdirectory + filename + "_cell_10m.ply") end1 = time.time() difftime1 = end1 - start1 print(("feature calc: %f sec") % (difftime1))
pc = read_las.read(args.input) f = open(args.kdtree, 'rb') kdtree = pickle.load(f) f.close() start1 = time.time() compute_features(pc, kdtree, 0, pc, [ 'max_z', 'min_z', 'mean_z', 'median_z', 'std_z', 'var_z', 'range', 'coeff_var_z', 'skew_z', 'kurto_z', 'sigma_z', 'perc_20', 'perc_40', 'perc_60', 'perc_80', 'pulse_penetration_ratio', 'density_absolute_mean' ], Sphere(np.float(args.radius))) """ feadataframe=pd.DataFrame({'_x':pc[point]['x']['data'],'_y':pc[point]['y']['data'],'_z':pc[point]['z']['data'], 'max_z':pc[point]['max_z']['data'],'min_z':pc[point]['min_z']['data'], 'mean_z':pc[point]['mean_z']['data'], 'median_z':pc[point]['median_z']['data'],'std_z':pc[point]['std_z']['data'], 'var_z':pc[point]['var_z']['data'], 'range':pc[point]['range']['data'],'coeff_var_z':pc[point]['coeff_var_z']['data'], 'skew_z':pc[point]['skew_z']['data'],'kurto_z':pc[point]['kurto_z']['data'], 'pulse_penetration_ratio':pc[point]['pulse_penetration_ratio']['data'],'density_absolute_mean':pc[point]['density_absolute_mean']['data'], 'sigma_z':pc[point]['sigma_z']['data'], 'perc_20':pc[point]['perc_20']['data'], 'perc_40':pc[point]['perc_40']['data'],'perc_60':pc[point]['perc_60']['data'], 'perc_80':pc[point]['perc_80']['data']}) feadataframe.to_csv(args.output,sep=";",index=False) """ end1 = time.time() difftime1 = end1 - start1 print(("feature calc: %f sec") % (difftime1)) write(pc, args.output)
def load(input_las_path, output_ply_path): pc = read_las.read(input_las_path) write_ply.write(pc, output_ply_path)
def test_write_loadTheSame(self): """ Writing a point cloud and loading it afterwards should result in the same point cloud. """ pc = generate_test_point_cloud() write(pc, self.test_file_path) loaded = read_ply(self.test_file_path) np.testing.assert_allclose(loaded, pc)
def test_write_sameFileTwice(self): """ Should not throw an exception. """ pc = generate_test_point_cloud() write(pc, self.test_file_path) write(pc, self.test_file_path)
def test_write_nonExistingFile(self): """ Should create a file. """ pc = generate_test_point_cloud() write(pc, self.test_file_path) assert (os.path.exists(self.test_file_path))