How to use the laspy.util.Format function in laspy

To help you get started, we’ve selected a few laspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github laspy / laspy / laspy / tools / lascopy.py View on Github external
laspy to try to preserve as much as possible, specify -b=True, though 
                    this may be quite slow depending on the size of the dataset.""" 
                    % (old_point_format, point_format))


        ## Build the new header, check if we need to do anythin special. This includes:
        ## 1. Check if there are extra dimensions defined which we need to copy.
        ## 2. Check if we need to get rid of some/all EVLRs for the output file_version
        ## 3. See if we need to re-map legacy fields for 1.4 files.
        try:
            new_header = inFile.header.copy()
            new_header.format = file_version 
            new_header.data_format_id = point_format

            old_data_rec_len = new_header.data_record_length
            old_std_rec_len = laspy.util.Format(old_point_format).rec_len
            diff =   old_data_rec_len - old_std_rec_len
            if (diff > 0):
                print("Extra Bytes Detected.")

            new_header.data_record_length = laspy.util.Format(point_format).rec_len + ((diff > 0)*diff)
            evlrs = inFile.header.evlrs
            if file_version != "1.4" and old_file_version == "1.4":
                print("Warning: input file has version 1.4, and output file does not. This may cause truncation of header data.")
                new_header.point_return_count = inFile.header.legacy_point_return_count
                new_header.point_records_count = inFile.header.legacy_point_records_count
            if not (file_version in ["1.3", "1.4"]) and old_file_version in ["1.3", "1.4"]:
                print("Stripping any EVLRs")
                evlrs = []
            if (file_version == "1.3" and len(inFile.header.evlrs) > 1):
                print("Too many EVLRs for format 1.3, keeping the first one.")
                evlrs = inFile.header.evlrs[0]
github laspy / laspy / laspy / header.py View on Github external
def __init__(self, data_type = 0, options = 0, name = "\x00"*32,
                 unused = [0]*4, no_data = [0.0]*3, min = [0.0]*3, 
                 max = [0.0]*3, scale = [1.0]*3, offset = [0.0]*3,
                 description = "\x00"*32):
        self.fmt = util.Format("extra_bytes_struct")
        self.packer = struct.Struct(self.fmt.pt_fmt_long)
        self.writeable = True
        self.vlr_parent = False
        self.names = [x.name for x in self.fmt.specs]

        self.data = b"\x00"*192
        self.set_property("data_type" , data_type)
        self.set_property("options" , options)
        self.set_property("name" , name + "\x00"*(32-len(name)))
        self.set_property("unused" , unused )
        self.set_property("no_data" , no_data)
        self.set_property("min" , min)
        self.set_property("max" , max)
        self.set_property("scale" , scale )
        self.set_property("offset" , offset)
        self.set_property("description" , description + "\x00"*(32-len(description)))
github laspy / laspy / laspy / base.py View on Github external
def correct_rec_len(self):
        extrabytes = self.header.data_record_length-laspy.util.Format(self.header.data_format_id).rec_len
        if extrabytes >= 0:
            self.point_format = laspy.util.Format(self.header.data_format_id,extra_bytes= extrabytes)
        else:
            self.point_format = laspy.util.Format(self.header.data_format_id)
            self.set_header_property("data_record_length", self.point_format.rec_len)
github laspy / laspy / laspy / base.py View on Github external
def correct_rec_len(self):
        extrabytes = self.header.data_record_length-laspy.util.Format(self.header.data_format_id).rec_len
        if extrabytes >= 0:
            self.point_format = laspy.util.Format(self.header.data_format_id,extra_bytes= extrabytes)
        else:
            self.point_format = laspy.util.Format(self.header.data_format_id)
            self.set_header_property("data_record_length", self.point_format.rec_len)
github laspy / laspy / laspy / base.py View on Github external
def __init__(self,filename, mode, header=False, vlrs=False, evlrs=False):
        '''Build the FileManager object. This is done when opening the file
        as well as upon completion of file modification actions like changing the
        header padding.'''
        self.compressed = False
        self.vlr_formats = laspy.util.Format("VLR")
        self.evlr_formats = laspy.util.Format("EVLR")
        self.mode = mode
        self.data_provider = DataProvider(filename, self)
        self.setup_memoizing()
        self.calc_point_recs = False
        self.point_refs = False
        self._current = 0
        self.padded = False
        if self.mode in ("r", "r-"):
            self.setup_read_write(vlrs,evlrs, read_only=True)
            return
        elif self.mode == "rw":
            self.setup_read_write(vlrs, evlrs, read_only=False)
            return
        elif self.mode == "w":
            self.setup_write(header, vlrs, evlrs)
github laspy / laspy / laspy / header.py View on Github external
self.reader = False
        self.body_fmt = None
        try:
            self.rec_len_after_header = len(self.VLR_body)
        except(TypeError):
            self.rec_len_after_header = 0
        if "description" in kwargs:
            self.description = str(kwargs["description"]) + "\x00"*(32-len(kwargs["description"]))
        else:
            self.description = "\x00"*32
        if "reserved" in kwargs:
            self.reserved = kwargs["reserved"]
        else:
            self.reserved = 0
        self.isVLR = True
        self.fmt = util.Format("VLR")
        if "LASF_Spec" in self.user_id and self.record_id == 4:
            self.setup_extra_bytes_spec(self.VLR_body)
        try:
            self.parse_data()
        except Exception as err:
            print("Error Parsing VLR Body Data:")
            print(err)