Skip to content

Instantly share code, notes, and snippets.

@kwinkunks
Created March 19, 2021 13:50
Show Gist options
  • Save kwinkunks/2992ebe05031c33fa9b52af6231f5654 to your computer and use it in GitHub Desktop.
Save kwinkunks/2992ebe05031c33fa9b52af6231f5654 to your computer and use it in GitHub Desktop.
Make a plain PPM image from 3 wireline logs in a LAS file
#!/usr/bin/gawk -f
#
# This file makes 8-bit RGB images from 3 logs
# The output is PLAIN (not RAW) PPM
# You need an LAS file containing only these logs
# Then run this script on that LAS file
# The Height should be set to the number of samples in the logs
#
# Set up the PGM Plain File format header
BEGIN {
skipping = 1
maxK = maxT = maxU = 1
printf "P3\n# from las2ppm\n100 4040\n20000\n"
}
#
# Rows of pixels have the form
# r g b r g b r g b r g b r g b
# Parse the las file and adjust the range
$1 != "~A" && skipping == 1 {next}
$1 == "~A" {skipping = 0; next}
{
if ($2 = -999.2500)
K = 0
else
K = $2*1000
if ($3 = -999.2500)
T = 0
else
T = $3*1000
if ($4 = -999.2500)
U = 0
else
U = $4*1000
for (column=1; column <= 100; column++)
{
printf "%-10d %10d %10d\n",K, T, U
if (maxK > K) maxK = K
if (maxT > T) maxT = T
if (maxU > T) maxU = U
}
}
#END {print maxK, maxT, maxU}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment