forked from KipCrossing/geotiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
52 lines (46 loc) · 1.61 KB
/
example.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
import os
import numpy as np # type: ignore
from geotiff import GeoTiff # type: ignore
filename = "dem.tif"
# filename = "red.tif"
dir = "./tests/inputs/"
tiff_file = os.path.join(dir, filename)
area_box = ((138.632071411, -32.447310785), (138.644218874, -32.456979174))
if __name__ == "__main__":
print("testing read tiff")
print(f"reading: {tiff_file}")
print(f"Using bBox: {area_box}")
geo_tiff: GeoTiff = GeoTiff(tiff_file, crs_code=4326, as_crs=4326, band=0)
print()
print(geo_tiff.crs_code)
print(geo_tiff.as_crs)
print(geo_tiff.tif_shape)
print(geo_tiff.tif_bBox)
print(geo_tiff.tif_bBox_wgs_84)
print(geo_tiff.tif_bBox_converted)
i = 5
j = 6
print(geo_tiff.get_coords(i, j))
print(geo_tiff.get_wgs_84_coords(i, j))
zarr_array = geo_tiff.read()
print(zarr_array)
print(np.array(zarr_array))
array = geo_tiff.read_box(area_box)
small_zarr_array = geo_tiff.read_box(area_box, aszarr=True)
int_box = geo_tiff.get_int_box(area_box)
print(int_box)
wgs_84_box = geo_tiff.get_bBox_wgs_84(area_box)
print(wgs_84_box)
int_box = geo_tiff.get_int_box(area_box, outer_points=2)
print(int_box)
wgs_84_box = geo_tiff.get_bBox_wgs_84(area_box, outer_points=2)
print(wgs_84_box)
i = int_box[0][0] + 5
j = int_box[0][1] + 6
print(geo_tiff.get_wgs_84_coords(i, j))
lon_array, lat_array = geo_tiff.get_coord_arrays(area_box, outer_points=2)
print(np.array(lon_array))
print(np.array(lat_array))
lon_array, lat_array = geo_tiff.get_coord_arrays()
print(np.array(lon_array))
print(np.array(lat_array))