# laspy.header module

## LasHeader

class laspy.header.LasHeader(*, version: Version | str | None = None, point_format: PointFormat | int | None = None)

  Bases: `object`

  Contains the information from the header of as LAS file with ‘implementation’ field left out and ‘users’ field stored in more ergonomic classes.

  This header also contains the VLRs

  Examples

  Creating a default header:

      >>> header = LasHeader()
      >>> header
      <LasHeader(1.2, <PointFormat(3, 0 bytes of extra dims)>)>

  Creating a header with the wanted version and point format:

      >>> header = LasHeader(version=Version(1, 4), point_format=PointFormat(6))
      >>> header
      <LasHeader(1.4, <PointFormat(6, 0 bytes of extra dims)>)>

      >>> header = LasHeader(version="1.4", point_format=6)
      >>> header
      <LasHeader(1.4, <PointFormat(6, 0 bytes of extra dims)>)>

  DEFAULT_VERSION = (1, 2)

    The default version used when None is given to init

  DEFAULT_POINT_FORMAT = <PointFormat(3, 0 bytes of extra dims)>

    The default point format Used when None is given to init

  file_source_id: int

    File source id

  uuid: UUID

    Project ID Initialized to null UUID

  system_identifier: str | bytes

    System identifier Initialized to ‘OTHER’

  generating_software: str | bytes

    The software which generated the file Initialized to ‘laspy’

  creation_date: date | None

    Day the file was created, initialized to date.today

  point_count: int

    The number of points in the file

  scales: ndarray

    The numbers used to scale the x,y,z coordinates

  offsets: ndarray

    The numbers used to offset the x,y,z coordinates

  number_of_points_by_return: ndarray

    Number of points by return for las <= 1.2 only the first 5 elements matters

  extra_header_bytes: bytes

    Extra bytes between end of header and first vlrs

  extra_vlr_bytes: bytes

    Extra bytes between end of vlr end first point

  start_of_waveform_data_packet_record: int

    Las >= 1.3

  start_of_first_evlr: int

    Las >= 1.4 Offset to the first evlr in the file

  number_of_evlrs: int

    The number of evlrs in the file

  max_gps_time: float

    Las >= 1.5 Max value of GPS Time

  min_gps_time: float

    Min value of GPS Time

  gps_time_offset: int

    Used to optimize GPS Time precision

  evlrs: VLRList | None

    EVLRs, even though they are not stored in the ‘header’ part of the file we keep them in this class as they contain same information as vlr. None when the file does not support EVLR

  property point_format: PointFormat

    The point format

  property version: Version

    The version

  property x_scale: float
  property y_scale: float
  property z_scale: float
  property x_offset: float
  property y_offset: float
  property z_offset: float
  property x_max: float
  property y_max: float
  property z_max: float
  property x_min: float
  property y_min: float
  property z_min: float
  property vlrs: VLRList
  add_extra_dims(params: List[ExtraBytesParams]) → None
  add_extra_dim(params: ExtraBytesParams)
  add_crs(crs: pyproj.CRS, keep_compatibility: bool = True) → None

    Add a Coordinate Reference System VLR from a pyproj CRS object.

    The type of VLR created depends on the las version and point format version. Las version >= 1.4 use WKT string, las version < 1.4 and point format < 6 use GeoTiff tags.

    Warning

    This requires pyproj.

    Warning

    Not all CRS are supported when adding GeoTiff tags. For example, custom CRS.

    Typically, if the CRS has an EPSG code it will be supported.

  remove_extra_dim(name: str) → None
  remove_extra_dims(names: Iterable[str]) → None
  set_version_and_point_format(version: Version, point_format: PointFormat) → None
  grow(points: PackedPointRecord) → None
  max_point_count() → int
  copy()
  parse_crs(prefer_wkt=True) → pyproj.CRS | None

    Method to parse OGC WKT or GeoTiff VLR keys into a pyproj CRS object

    Returns None if no CRS VLR is present, or if the CRS specified in the VLRS is not understood.

    Parameters:

      - prefer_wkt (Optional, default True,) – If True the WKT VLR will be preferred in case both the WKT and Geotiff VLR are present

      - warning:: (..) – This requires pyproj.

      - versionadded: (..) – 2.5: The `prefer_wkt` parameters.

  read_evlrs(stream)

    Reads EVLRs from the stream and sets them in the data property.

    The evlrs are accessed from the evlrs property

    Does nothing if either of these is true:

      - The file does not support EVLRS (version < 1.4)

      - The file has no EVLRS

      - The stream does not support seeking

    Leaves/restores the stream position to where it was before the call

  property major_version: int
  property minor_version: int