-
-
Save grantbrown/cb6c7317bbf6f8ec7b26 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, struct, sys, glob | |
import laspy | |
#def worker_bee(inLAS): | |
def build_geotiff(): | |
### Define GeoTiff ASCII parameters ### | |
GTCitGeoKey = 'PCS Name = NAD_1983_2011_StatePlane_Florida_East_FIPS_0901_Ft_US' + '|' | |
VertCitGeoKey = 'NAVD88 - Geoid12B (Feet)' + '|' | |
# Build GeoAsciiParamsTag Record | |
vlr_body2 = GTCitGeoKey + VertCitGeoKey + '\x00' | |
# Build GeoTiff Projection Keys VLRs | |
sGeoKey1 = struct.pack('4H', 1, 1, 0, 6) | |
### sKeyEntry ### | |
# sKeyEntry = [wKeyID, wTIFFTagLocation, wCount, wValue_Offset] | |
# GTModelTypeGeoKey: ModelTypeProjected | |
sKeyEntry1 = struct.pack('4H', 1024, 0, 1, 1) | |
# GTCitationGeoKey: Custom | |
sKeyEntry2 = struct.pack('4H', 1026, 34737, len(GTCitGeoKey), 0) | |
# ProjLinearUnitsGeoKey: Linear_Foot_US_Survey | |
sKeyEntry3 = struct.pack('4H', 3076, 0, 1, 9003) | |
# VerticalCSTypeGeoKey: VertCS_North_American_Vertical_Datum_1988 | |
sKeyEntry4 = struct.pack('4H', 4096, 0, 1, 5103) | |
# VerticalCitationGeoKey: Custom | |
sKeyEntry5 = struct.pack('4H', 4097, 34737, len(VertCitGeoKey), len(GTCitGeoKey)) | |
# VerticalUnitsGeoKey: Linear_Foot_US_Survey | |
sKeyEntry6 = struct.pack('4H', 4099, 0, 1, 9003) | |
# Combine strings | |
vlr_body1 = sGeoKey1 + sKeyEntry1 + sKeyEntry2 + sKeyEntry3 + sKeyEntry4 + sKeyEntry5 + sKeyEntry6 | |
new_vlr1 = laspy.header.VLR(user_id = 'LASF_Projection', | |
record_id = 34735, | |
VLR_body = vlr_body1, | |
description = "GeoTiff Projection Keys") | |
new_vlr2 = laspy.header.VLR(user_id = 'LASF_Projection', | |
record_id = 34737, | |
VLR_body = vlr_body2, | |
description = "GeoTiff ASCII parameters") | |
new_vlrs = [new_vlr1, new_vlr2] | |
return new_vlrs | |
if __name__ == "__main__": | |
# Read LAS files | |
#las_files = glob.glob(sys.argv[1]) | |
las_file = "./simple.las" | |
# Sort ascending order | |
# Loop | |
for i in xrange(10000): | |
print(i) | |
f = laspy.file.File(las_file, mode='rw') | |
inVLRs = build_geotiff() | |
f.header.vlrs = inVLRs | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment