Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add simple command line tool for adding a percentage of noise to a la…

…s file
  • Loading branch information...
commit b6966a9bb3092ae071db041a8a6eae25e742b104 1 parent 87c0824
@grantbrown authored
Showing with 35 additions and 0 deletions.
  1. +34 −0 laspy/tools/lasnoise.py
  2. +1 −0  setup.py
View
34 laspy/tools/lasnoise.py
@@ -0,0 +1,34 @@
+import argparse
+from laspy.file import File
+import numpy as np
+from math import floor
+
+def main():
+ parser =argparse.ArgumentParser(description = """Open a file in rw mode and add random noise to X Y and Z.""")
+ parser.add_argument("in_file", metavar = "in_file",
+ type=str,nargs="+",help = "LAS file to screw with.")
+ parser.add_argument("--x_pct", metavar = "x_pct", type = float,default = 10, help = "Percent Of X Points to jiggle")
+ parser.add_argument("--y_pct", metavar = "y_pct", type = float,default = 10, help = "Percent Of X Points to jiggle")
+ parser.add_argument("--z_pct", metavar = "z_pct", type = float,default = 10, help = "Percent Of X Points to jiggle")
+ args = parser.parse_args()
+
+
+
+ inFile = File(args.in_file[0], mode = "rw")
+
+
+ def gen_noise(pct, length):
+ out = np.zeros(length)
+ indices = np.random.random_integers(0,length-1, floor(float(pct)/100*length))
+ vals = np.random.random_integers(-3,3, len(indices))
+ out[indices] += vals
+ return(out)
+
+ inFile.X += gen_noise(args.x_pct, len(inFile))
+ inFile.Y += gen_noise(args.y_pct, len(inFile))
+ inFile.Z += gen_noise(args.z_pct, len(inFile))
+ inFile.header.update_min_max()
+ inFile.close(ignore_header_changes=True)
+
+
+
View
1  setup.py
@@ -45,6 +45,7 @@
zip_safe = False,
entry_points = {'console_scripts':['lascopy = laspy.tools.lascopy:main',
'lasexplorer = laspy.tools.lasexplorer:main',
+ 'lasnoise = laspy.tools.lasnoise:main',
'lasverify = laspy.tools.lasverify:main',
'lasvalidate = laspy.tools.lasvalidate:main',
'lasviewer = laspy.tools.lasviewer:main'
Please sign in to comment.
Something went wrong with that request. Please try again.