Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
really_copyfile(self.simple, self.tempfile)
self.File1 = File.File(self.tempfile, mode = "rw")
def save_las(inFilename,outFilename):
road_file = File.File(inFilename)
new_header = copy.copy(road_file.header)
tmp_File = File.File(outFilename, mode = "w",header=new_header)
for spec in road_file.reader.point_format:
# print("Copying dimension: " + spec.name)
in_spec = road_file.reader.get_dimension(spec.name)
try:
tmp_File.writer.set_dimension(spec.name, in_spec)
except(util.LaspyException):
print("Couldn't set dimension: " + spec.name +
" with file format " + str(tmp_File.header.version) +
", and point_format " + str(tmp_File.header.data_format_id))
road_file.close()
return tmp_File
def setup(self):
# Check mode
print("Reading: " + self.args.in_file[0])
self.mode = self.args.mode
self.dim = self.args.dimension
try:
inFile = laspy.file.File(self.args.in_file[0], mode = "r")
self.inFile = inFile
except Exception as error:
print("Error while reading file:")
print(error)
quit()
def get_bbox_of_multiple_tiles(file_list,laz_files=False,return_zlim=False):
las_files = np.genfromtxt(file_list,delimiter=',',dtype='S256')
n_files = las_files.size
if laz_files:
temp_file = 'temp_%i.las' % np.round(np.random.random()*10**9).astype(int)
os.system("las2las %s %s" % (las_files[0],temp_file))
lasFile = las.file.File('%s' % temp_file,mode='r-')
max_xyz = lasFile.header.max
min_xyz = lasFile.header.min
xmin = min_xyz[0]
ymin = min_xyz[1]
xmax = max_xyz[0]
ymax = max_xyz[1]
zmin = min_xyz[2]
zmax = max_xyz[2]
lasFile.close()
os.system("rm %s" % temp_file)
for i in range(1,n_files):
temp_file = 'temp_%i.las' % np.round(np.random.random()*10**9).astype(int)
os.system("las2las %s %s" % (las_files[i],temp_file))
lasFile = las.file.File('%s' % temp_file,mode='r-')
max_xyz = lasFile.header.max
def to_las(pc, fname, scale=None, store_rgb=True):
"""Write pc to LAS file with name fname. Destroys pc.
Reuses original scale if no scale is specified; can cause precision loss.
"""
if hasattr(pc, "_las_header"):
header = pc._las_header
else:
header = laspy.header.Header()
format_id = 2 if store_rgb else 1 # see LAS standard
f = laspy.file.File(fname, mode='w', header=header)
f.header.set_dataformatid(format_id)
f.header.offset = pc.offset.tolist()
def validate(self):
print("Reading in file: " + self.args.in_file[0])
inFile = laspy.file.File(self.args.in_file[0], mode = "r")
self.test0(inFile)
self.test1(inFile)
self.test2(inFile)
self.test3(inFile)
print(str(self.errors) + " errors out of " + str(self.tests) + " tests")
# author: niranjanreddy891@gmail.com
from laspy.file import File
import numpy as np
inFile = File('E:/Lidar-practice/new-files/las14_type7_ALS_RIEGL_Q680i.las', mode='r')
I = inFile.Classification == 2
outFile = File('E:/Lidar-practice/new-files/tttttttttttt.pcd', mode='w', header=inFile.header)
outFile.points = inFile.points[I]
outFile.close()
# loop through las file and populate multi-dimensional grid
# create rhp and rhi, multi-dimensional output grids - rhp is density, rhi is intensity sum
rhp = numpy.zeros((chmMax,dtm_y_shape,dtm_x_shape))
rhi = numpy.zeros((chmMax,dtm_y_shape,dtm_x_shape))
chm2 = numpy.zeros((dtm_y_shape,dtm_x_shape))
print 'created them!'
bands,nrows,ncols = rhp.shape
print "Populating Voxels"
for lasfile in lasfiles:
print "Iterating over points in files %s" %(lasfile)
sys.stdout.flush()
f = file.File(lasfile,mode='r')
for p in f:
# print 'x,y,z: ', p.x, p.y, p.z
p.make_nice()
x = scale_x(f, p)
y = scale_y(f, p)
z = scale_z(f, p)
c = p.classification
i = p.intensity
col = coldex(x, dtm_minx, 1.0)
row = rowdex(y, dtm_maxy, 1.0)
if (0 <= col < dtm_x_shape) & (0 <= row < dtm_y_shape):
zd = get_dtm_value(dtm_arr, x, y, dtm_minx, dtm_maxy, 1.0, dtm_y_shape, dtm_x_shape)
z2 = z-zd