laspy.header module¶
LasHeader¶
- class laspy.header.LasHeader(*, version: Optional[Union[Version, str]] = None, point_format: Optional[Union[PointFormat, int]] = None)[source]¶
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 = Version(major=1, minor=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
- generating_software: Union[str, bytes]¶
The software which generated the file Initialized to ‘laspy’
- 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
- evlrs: Optional[VLRList]¶
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
- add_extra_dims(params: List[ExtraBytesParams]) None [source]¶
- add_extra_dim(params: ExtraBytesParams)[source]¶
- add_crs(crs: pyproj.CRS, keep_compatibility: bool = True) None [source]¶
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.
- set_version_and_point_format(version: Version, point_format: PointFormat) None [source]¶
- grow(points: PackedPointRecord) None [source]¶
- parse_crs(prefer_wkt=True) Optional[pyproj.CRS] [source]¶
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)[source]¶
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