How to use the laspy.header.HeaderManager 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 / base.py View on Github external
def setup_write(self,header, vlrs, evlrs):
        self._header_current = False
        if header == False:
            raise laspy.util.LaspyException("Write mode requires a valid header object.")
        ## No file to store data yet.
        self.has_point_records = False
        self.data_provider.open("w+b")
        self.header_format = header.format
        self._header = header
        self.header = laspy.header.HeaderManager(header = header, reader = self)
        self.initialize_file_padding(vlrs)

        ## We have a file to store data now.
        self.data_provider.remap()
        self.header.flush()

        self.correct_rec_len()
        if not vlrs in [[], False]:
            self.set_vlrs(vlrs)
        else:
            self.vlrs = []
        if not evlrs in [[], False]:
            self.set_evlrs(evlrs)
        else:
            self.evlrs = []
        self.verify_num_vlrs()
github laspy / laspy / laspy / base.py View on Github external
def get_header(self, file_version = 1.2):
        '''Return the header object, or create one if absent.'''
        ## Why is this != neccesary?
        try:
            return(self.header)
        except:
            self.header = laspy.header.HeaderManager(header = laspy.header.Header(file_version), reader = self)
            return(self.header)
github brycefrank / pyfor / pyfor / cloud.py View on Github external
def __init__(self, points, header):

        # Assign useful shortcuts
        # TODO expand
        self.points = points
        self.x = self.points[:, 0]
        self.y = self.points[:, 1]
        self.z = self.points[:, 2]

        if type(header) == laspy.header.HeaderManager:
            self.header = header.copy()
        else:
            self.header = header

        self.header.min = [np.min(self.x), np.min(self.y), np.min(self.z)]
        self.header.max = [np.max(self.x), np.max(self.y), np.max(self.z)]
        self.header.count = np.alen(self.points)
github laspy / laspy / laspy / file.py View on Github external
if self._header is None:
                self._writer = base.Writer(self.filename,mode = self._mode)
                self._reader = self._writer
                self._header = self._reader.get_header()
                ## Wire up API for any extra Dimensions
                if self._writer.extra_dimensions != []:
                    for dimension in self._writer.extra_dimensions:
                        dimname = dimension.name.decode().replace("\x00", "").replace(" ", "_").lower()
                        self.addProperty(dimname) 
            else:
                raise util.LaspyException("Headers must currently be stored in the file, you provided: " + str(self._header))
    
        elif self._mode == 'w': 
            if self._header is None:
                raise util.LaspyException("Creation of a file in write mode requires a header object.")  
            if isinstance(self._header,  header.HeaderManager):
                vlrs = self._header.vlrs
                evlrs = self._header.evlrs
                self._header = self._header.copy() 
                if self._vlrs != False:
                    self._vlrs.extend(vlrs)
                else:
                    self._vlrs = vlrs
                if self._evlrs != False:
                    self._evlrs.extend(evlrs)
                else:
                    self._evlrs = evlrs

            self._writer = base.Writer(self.filename, mode = "w",
                                      header = self._header, 
                                      vlrs = self._vlrs, evlrs = self._evlrs)
            self._reader = self._writer
github brycefrank / pyfor / pyfor / cloud.py View on Github external
self._get_las_points(las)

            elif self.extension.lower() == '.ply':
                ply = plyfile.PlyData.read(path)
                ply_points = ply.elements[0].data
                points = pd.DataFrame({"x": ply_points["x"], "y": ply_points["y"], "z": ply_points["z"]})
                header = 'ply_header'
                self.data = PLYData(points , header)

            else:
                raise ValueError('File extension not supported, please input either a las, laz, ply or CloudData object.')

        elif type(path) == CloudData or isinstance(path, CloudData):
            self.data = path

            if type(self.data.header) == laspy.header.HeaderManager:
                self.data = LASData(self.data.points, self.data.header)

            elif self.data.header == 'ply_header':
                self.data = PLYData(self.data.points, self.data.header)

        elif path.__class__.__bases__[0] == laspy.file.File or type(path) == laspy.file.File:
            self._get_las_points(path)

        else:
            raise ValueError("Object type not supported, please input either a file path with a supported extension or a CloudData object.")

        # We're not sure if this is true or false yet
        self.normalized = None
        self.crs = None