Last active
March 22, 2019 05:25
-
-
Save sunapi386/71ebae8bdedede81b95d8d47d440ee9e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Author: Jason Sun [email protected] | |
# Date: Mar. 21, 2019 | |
# Print the merged bounds from ept.json files | |
# E.g. | |
# ~/wutm> merge_bounds.py | |
# ./frame1000.laz/ept.json [591595.0, 4137691.0, -27.0, 591677.0, 4137773.0, 55.0] | |
# ./frame0.laz/ept.json [591503.0, 4137321.0, -25.0, 591587.0, 4137405.0, 59.0] | |
# ./sample-utm.laz/ept.json [591470.0, 4137314.0, -114.0, 591724.0, 4137568.0, 140.0] | |
# ./frame2000.laz/ept.json [591657.0, 4137697.0, -28.0, 591739.0, 4137779.0, 54.0] | |
# ---- | |
# [591657.0, 4137697.0, -114.0, 591739.0, 4137779.0, 140.0] | |
# ~/wutm> | |
def get_all_ept_from_subdirectory(directory): | |
import os | |
cmd = 'find ' + directory + ' -type f -iname "ept.json"' | |
return [file for file in os.popen(cmd).read().split('\n')[0:-1]] | |
def get_bound_from_ept(ept_path): | |
import json | |
with open(ept_path) as f: | |
data = json.load(f) | |
return data['bounds'] | |
def merge_bounds(boundA, boundB): | |
zipped_bounds = zip(boundA, boundB) | |
unions = [] | |
for pair in zipped_bounds: | |
if abs(max(pair)) > abs(min(pair)): | |
unions.append(max(pair)) | |
else: | |
unions.append(min(pair)) | |
return unions | |
epts = get_all_ept_from_subdirectory('.') | |
if epts: | |
base_bound = get_bound_from_ept(epts[0]) | |
print(epts[0], base_bound) | |
for e in epts[1:]: | |
new_bound = get_bound_from_ept(e) | |
print(e, new_bound) | |
base_bound = merge_bounds(base_bound, new_bound) | |
print('----') | |
print(base_bound) | |
else: | |
from os import getcwd | |
print('did not find ept.json in subdirectory of', getcwd()) | |
# jq "[.minx, .miny, .minz, .maxx, .maxy, .maxz]" 1.stats.json |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Author: Jason Sun [email protected] | |
# Date: Mar. 21, 2019 | |
# Print the merged bounds from laz files | |
# E.g. | |
# ~/wutm> merge_bounds_laz.py | |
def get_all_laz_from_subdirectory(directory): | |
import os | |
cmd = 'find ' + directory + ' -type f -iname "*.laz"' | |
return [file for file in os.popen(cmd).read().split('\n')[0:-1]] | |
def get_bound_from_laz(laz_path): | |
import os | |
import json | |
cmd = 'pdal info ' + laz_path | |
json_file = os.popen(cmd).read() | |
# return [file for file in .split('\n')[0:-1]] | |
data = json.loads(json_file) | |
bbox = data['stats']['bbox']['native']['bbox'] | |
return [bbox['minx'], bbox['miny'], bbox['minz'], | |
bbox['maxx'], bbox['maxy'], bbox['maxz']] | |
def merge_bounds(boundA, boundB): | |
zipped_bounds = zip(boundA, boundB) | |
unions = [] | |
for pair in zipped_bounds: | |
if abs(max(pair)) > abs(min(pair)): | |
unions.append(max(pair)) | |
else: | |
unions.append(min(pair)) | |
return unions | |
lazs = get_all_laz_from_subdirectory('.') | |
if lazs: | |
base_bound = get_bound_from_laz(lazs[0]) | |
print(lazs[0], base_bound) | |
for e in lazs[1:]: | |
new_bound = get_bound_from_laz(e) | |
print(e, new_bound) | |
base_bound = merge_bounds(base_bound, new_bound) | |
print('----') | |
print(base_bound) | |
else: | |
from os import getcwd | |
print('did not find any laz files in subdirectory of', getcwd()) | |
# jq "[.minx, .miny, .minz, .maxx, .maxy, .maxz]" 1.stats.json |
for laz in (find . -iname "*.laz")
entwine build -i $laz -o outfolder -b "[500000.00, 4000000, -400.00, 625000.0, 4300000.0, 5000.00]"
end
to build all the laz files in california utm zone 10.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fish script get bounds from laz file into the entwine ordering