I have a text file, each line in the text file has X,Y and Z coordinates eg:
551124.5841823021 470778.1953796738 318.1167521614109
I want to read the data and export it to LAS format, by using laspy. The code I use, inspired from :
header = laspy.header.Header()
with open(input_file, "r") as file:
lines = list(line for line in (l.strip() for l in file) if line)
output_X = []
output_Y = []
output_Z = []
for line in lines:
splited = line.split()
output_X.append(float((splited[0])))
output_Y.append(float((splited[1])))
output_Z.append(float((splited[2])))
output_file = input_file.rsplit(".", 1)[0]+"_changed.las"
outfile = laspy.file.File(r"{}".format(output_file),
mode="w", header=header)
outfile.X = numpy.array(output_X)
outfile.Y = numpy.array(output_Y)
outfile.Z = numpy.array(output_Z)
outfile.close()
The values I expect to find should be of the same type as those from txt file, however, if I read the file I get:
[((551124, 470778, 318, 0, 0, 0, 0, 0, 0),) ((551124, 470779, 318, 0, 0, 0, 0, 0, 0),) ((551124, 470780, 318, 0, 0, 0, 0, 0, 0),) ... ((551438, 470707, 315, 0, 0, 0, 0, 0, 0),) ((551438, 470708, 315, 0, 0, 0, 0, 0, 0),) ((551438, 470709, 315, 0, 0, 0, 0, 0, 0),)]
I want the entries to be of type float, with decimal. I know it should be possible, since I have LAS files received from a third party, that have decimals. Should I be setting the scale for the LAS file on export? Also, if I open the output file in a software that reads LAS files, ArcGIS, points are not represented. What am I doing wrong?