Skip to content

Commit

Permalink
Add read_geotiff
Browse files Browse the repository at this point in the history
  • Loading branch information
yumorishita committed Feb 25, 2021
1 parent db454df commit 6769823
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion LiCSBAS_lib/LiCSBAS_io_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
Python3 library of input/output functions for LiCSBAS.
=========
Changelog
Change log
=========
v1.4 20210224 Yu Morioshita, GSI
- Add read_geotiff
v1.3 20210209 Yu Morioshita, GSI
- Add make_geotiff
v1.2.1 20201211 Yu Morioshita, GSI
Expand Down Expand Up @@ -166,6 +168,26 @@ def read_bperp_file(bperp_file, imdates):
return bperp


#%%
def read_geotiff(file, file_ref=None):
geotiff = gdal.Open(file)

if file_ref is not None: # Compare size and area
size = (geotiff.RasterXSize, geotiff.RasterYSize)
area = geotiff.GetGeoTransform()

geotiff_ref = gdal.Open(file_ref)
size_ref = (geotiff_ref.RasterXSize, geotiff_ref.RasterYSize)
area_ref = geotiff_ref.GetGeoTransform()

if not (size == size_ref and area == area_ref):
raise Exception('ERROR: File size or area are not identical between {} and {}'.format(file, file_ref))

data = geotiff.ReadAsArray()

return data


#%%
def read_img(file, length, width, dtype=np.float32, endian='little'):
"""
Expand Down

0 comments on commit 6769823

Please sign in to comment.