def _construct_tile(self, func, tile, indexed): """ For a given tile, clips points from intersecting las files and loads as Cloud object. :param func: The function to process the input tile. :param tile: Tile the tile to process :param indexed: A boolean indicating whether or not to leverage a `.lax` file. """ for i, las_file in enumerate(self._get_parents(tile)['las_path']): if indexed == True: try: las = laxpy.IndexedLAS(las_file) las.map_polygon(tile) except ValueError as e: print(e) return 0 else: las = las_file if i == 0: out_pc = pyfor.cloud.Cloud(las) else: out_pc.data._append(pyfor.cloud.Cloud(las).data) try: out_pc = out_pc.clip(tile) out_pc.crs = self.crs func(out_pc, tile) except KeyError as e: print(e) pass
def _construct_tile_indexed(self, func, tile, args): """ For a given tile, clips points from intersecting las files and loads as Cloud object. :param func: The function to process the input tile. :param tile: Tile the tile to process """ i = 0 for las_file in self._get_parents(tile)["las_path"]: # Map the index (clip) las = laxpy.IndexedLAS(las_file) las.map_polygon(tile) if len(las.x) > 0: if i == 0: out_pc = pyfor.cloud.Cloud(las) else: out_pc.data._append(pyfor.cloud.Cloud(las).data) out_pc = out_pc.clip(tile) out_pc.crs = self.crs i += 1 else: pass las.reader.close() if out_pc.data.points.shape[0] > 0: func(out_pc, tile)
def _index_las(self, las_path): """ Checks if an equivalent `.lax` file exists. If so, creates a laxpy.IndexedLAS object, otherwise an error is thrown. """ lax_path = las_path[:-1] + 'x' if os.path.isfile(lax_path): return laxpy.IndexedLAS(las_path) else: raise FileNotFoundError( 'There is no equivalent .lax file for this .las file.')
def map_poly(self, las_path, polygon): las = laxpy.IndexedLAS(las_path) las.map_polygon(polygon) return las.points