예제 #1
0
from laspy.file import File
#import numpy as np
#file_name='simple.las'
file_name='points.las'
inFile = File(file_name, mode='r')
print("inFile type",type(inFile))
I = inFile.Classification == 2
##
h = inFile.header
print("Version=",h.major_version,".",h.minor_version)
##
pts = inFile.get_points()
print("points type",type(pts))
print("points shape",pts.shape)

intensity = inFile.get_intensity()
print("intensity points shape",intensity.shape)

flag_byte = inFile.get_flag_byte()
print("flag_byte shape",flag_byte.shape)

pt_ret_count = inFile.point_return_count()
print("type of point return count", type(pt_ret_count))

ret_num = inFile.get_return_num()
print("ret_num shape",ret_num.shape)
print("ret_num shape 100",ret_num[100].shape)
print("First returned number",ret_num[0],"\n")
print("First returned number",ret_num[0],"\n")
unique_elements, counts_elements = np.unique(ret_num, return_counts=True)
print("Frequency of unique values of the said array:")
예제 #2
0
if os.path.exists(bootstrap_dir) == False:
    os.mkdir(bootstrap_dir)

figure_dir = os.path.join(args.outputdir, 'figure')
if os.path.exists(figure_dir) == False:
    os.mkdir(figure_dir)

pickle_dir = os.path.join(args.outputdir, 'pickle')
if os.path.exists(pickle_dir) == False:
    os.mkdir(pickle_dir)


### Loading data and filtering
print('\nLoading input file: %s'%args.inlas)
inFile = File(args.inlas, mode='r')
pc_xyzic = np.vstack((inFile.get_x()*inFile.header.scale[0]+inFile.header.offset[0], inFile.get_y()*inFile.header.scale[1]+inFile.header.offset[1], inFile.get_z()*inFile.header.scale[2]+inFile.header.offset[2], inFile.get_intensity(), inFile.get_classification())).transpose()
#pc_xyzic is now a point cloud with x, y, z, intensity, and classification
#if args.store_color == True:
#    pc_i = inFile.get_intensity().copy()
#    pc_blue = inFile.get_blue().copy()
#    pc_green = inFile.get_green().copy()
#    pc_red = inFile.get_red().copy()
print('Loaded %s points'%"{:,}".format(pc_xyzic.shape[0]))

if args.ground_only == True:
    print('\nFiltering points to only work with ground points (class == 2)... ',end='\n')
    #get only ground points:
    idx_ground = np.where(pc_xyzic[:,4] == 2)[0]
    pc_xyzig = pc_xyzic[idx_ground,0:4]
    pc_xyzg = pc_xyzic[idx_ground,0:3]
    #pc_xyzg is a point cloud with x, y, z, and for class == 2 only