How do I write a .LAS file from .mat data?

10 views (last 30 days)
Nicole Zuck
Nicole Zuck on 17 Jan 2022
Answered: Walter Roberson on 17 Jan 2022
I am trying to save XYZ data as a .LAS file to use in another program, but I keep getting the following error.
I am using the LASwrite function (see for the tool download).
The error message:
Dot indexing is not supported for variables of this type.
Error in LASwrite (line 106)
guid_1 = s.header.project_id_1;
Error in SurveyProcessing (line 83)
LASwrite(drone, 'D:\Drone LAS and tif files\2021.03.21\drone.las');
How do I fix my script? I'm not sure if the struct needs to be formatted differently, or is there is a better method entirely.
% first put data into a struct
drone.header = {}; % I've tried running it with and without this header
drone.X = droneX; % X Y and Z data are 890723x1 doubles representing stateplane coordinates and elevation
drone.Y = droneY;
drone.Z = droneZ;
% then use LASwrite (need tool download)
LASwrite(drone, 'D:\Drone LAS and tif files\2021.03.21\drone.las');

Answers (1)

Walter Roberson
Walter Roberson on 17 Jan 2022
guid1 = uint32(0); %32 bit
guid2 = uint16(0); %16 bit
guid3 = uint16(0); %16 bit
guid3 = blanks(8); %unsigned char 8 bytes
drone.header = struct('project_id_1', guid1, 'project_id_2', guid2, 'project_id_3', guid3, 'project_id_4', guid4);
Under at least some circumstances, the header might perhaps also require fields named
  • offset_to_evlr
  • number_of_evlr
  • n_points_by_return
  • n_points_by_return_extended

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by