How to use the laspy.header.Header 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 icesat-2UT / PhoREAL / source_code / icesatIO.py View on Github external
def writeLas(xx,yy,zz,proj,output_file,classification,intensity,signalConf=None,hemi=None,zone=None):
    wkt = selectwkt(proj,hemi,zone)
    
    #Create new VLR
    new_vlr = laspy.header.VLR(user_id = "LASF_Projection",
                           record_id = 2112,
                           VLR_body = wkt,
                           description = "OGC Coordinate System WKT")
    inVLRs = []
    inVLRs.append(new_vlr)

    #Create new Header
    hdr = laspy.header.Header(file_versoin=1.4 )
    hdr.file_sig = 'LASF'
    
    #Create new las file with Header and VLR  
    outfile = laspy.file.File(output_file, mode="w", header=hdr)
    outfile.header.vlrs = inVLRs
    outfile.header.set_wkt = 1
    
    #Establish offset
    xmin = np.min(xx)
    ymin = np.min(yy)
    zmin = np.min(zz)
    
    xmax = np.max(xx)
    ymax = np.max(yy)
    zmax = np.max(zz)
github davidcaron / pclpy / pclpy / io / las.py View on Github external
def write(cloud, path, write_extra_dimensions=True, scale=0.0001, xyz_offset=None):
    has = lambda x: hasattr(cloud, x)

    if not all([has("x") and has("y") and has("z")]):
        raise ValueError("Not a XYZ point type %s" % type(cloud))

    has_color = has("r") and has("g") and has("b")
    point_format = 0
    if has_color:
        point_format = 2
    header = laspy.header.Header(point_format=point_format)

    with laspy.file.File(path, mode="w", header=header) as f:
        extra_dims = []
        if write_extra_dimensions:
            extra_dims = get_extra_dims(cloud)
            for dim in extra_dims:
                data_type = get_las_data_type(getattr(cloud, dim))
                f.define_new_dimension(dim, data_type, dim)

        f.header.scale = (scale, scale, scale)

        if xyz_offset is not None:
            f.header.offset = xyz_offset
            f.x = cloud.x.astype("d") + xyz_offset[0]
            f.y = cloud.y.astype("d") + xyz_offset[1]
            f.z = cloud.z.astype("d") + xyz_offset[2]
github laempy / pyoints / pyoints / storage / LasHandler.py View on Github external
def _createTypeTestLas(outfile):
    # experimental

    # Create file header
    header = laspy.header.Header()
    header.file_sig = 'LASF'
    header.format = 1.2
    header.data_format_id = 3

    # Open file in write mode
    lasFile = laspy.file.File(outfile, mode='w', header=header)

    lasFile.header.scale = [1, 1, 1]
    lasFile.header.offset = [0, 0, 0]

    names = []
    for type_id in range(1, 31):
        name = 'field_%i' % type_id
        if type_id not in [8, 18, 28]:
            lasFile.define_new_dimension(name, type_id, '')
            names.append(name)
github NLeSC / PattyAnalytics / patty / registration / registered_pointcloud.py View on Github external
def to_las(pc, fname, scale=None, store_rgb=True):
    """Write pc to LAS file with name fname. Destroys pc.

    Reuses original scale if no scale is specified; can cause precision loss.
    """
    if hasattr(pc, "_las_header"):
        header = pc._las_header
    else:
        header = laspy.header.Header()

    format_id = 2 if store_rgb else 1       # see LAS standard

    f = laspy.file.File(fname, mode='w', header=header)
    f.header.set_dataformatid(format_id)
    f.header.offset = pc.offset.tolist()
github laempy / pyoints / pyoints / storage / LasHandler.py View on Github external
Desired LAS point format. See LAS specification for details.

    """
    # validate input
    if not isinstance(geoRecords, GeoRecords):
        raise TypeError("'geoRecords' needs to be of type 'GeoRecords'")
    if not os.access(os.path.dirname(outfile), os.W_OK):
        raise IOError('File %s is not writable' % outfile)

    if point_format not in SUPPORTED_FORMATS:
        raise ValueError("'point_format' %s not supported" % str(point_format))

    records = geoRecords.records()

    # Create file header
    header = laspy.header.Header(file_version=1.3, point_format=point_format)
    header.file_sig = 'LASF'

    # Open file in write mode
    lasFile = laspy.file.File(outfile, mode='w', header=header)

    # create VLR records
    vlrs = []
    if 'liblas' in sys.modules:
        # use liblas to create spatial reference
        srs = liblas.srs.SRS()
        srs.set_wkt(str.encode(geoRecords.proj.wkt))
        for i in range(srs.vlr_count()):
            vlr = laspy.header.VLR(
                user_id="LASF_Projection",
                record_id=srs.GetVLR(i).recordid,
                VLR_body=srs.GetVLR(i).data,