-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathio_utilities.py
63 lines (54 loc) · 1.5 KB
/
io_utilities.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
import numpy as np
import os
class Tinfile:
"""Set up TIN file class for LIDAR data
Members:
nx: # samples in x
ny: # samples in y
ox: origin in x
oy: origin in y
dx: sample interval in x
dy: sample interval in y
data: elevation data
"""
nx=None
ny=None
dx=None
dy=None
ox=None
oy=None
data=None
def __init__(self):
self.data = []
def Read_In_TIN(myfile,verb=False):
"""Read in a TIN file and return a class
Input:
file (string): the input path and file name
verb (logical;optional): be verbose
Output:
tin (class)"""
tin = Tinfile()
with open(myfile, "r") as ins:
array = []
for line in ins:
array.append(line)
tin.nx=int(array[0][5:])
tin.ny=int(array[1][5:])
tin.ox=float(array[2][10:])
tin.oy=float(array[3][10:])
tin.dx=float(array[4][9:])
tin.dy=float(array[4][9:])
if(verb):
print('Reading in TIN file %s'%(myfile))
print('NX: %d'%(tin.nx))
print('NY: %d'%(tin.ny))
print('OX: %f'%(tin.ox))
print('OY: %f'%(tin.oy))
print('DX: %g'%(tin.dx))
print('DY: %g'%(tin.dy))
alldata = np.zeros((tin.nx,tin.ny));
for ii in range(0,tin.ny):
alldata[:,ii]=array[ii+6].split();
tin.data = np.reshape(alldata,(tin.nx,tin.ny));
return tin;