Apply current workspace changes
This commit is contained in:
+76
@@ -0,0 +1,76 @@
|
||||
#! /usr/bin/env python
|
||||
#################################################################
|
||||
### This program is part of PyINT v2.1 ###
|
||||
### Copy Right (c): 2017-2019, Yunmeng Cao ###
|
||||
### Author: Yunmeng Cao ###
|
||||
### Contact : ymcmrs@gmail.com ###
|
||||
#################################################################
|
||||
import numpy as np
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import os
|
||||
import warnings
|
||||
|
||||
from osgeo import gdal, osr
|
||||
|
||||
from mintpy.utils import plot as pp, readfile, utils0 as ut
|
||||
|
||||
# link: https://gdal.org/drivers/raster/index.html
|
||||
GDAL_DRIVER2EXT = {
|
||||
'GTiff' : '.tif',
|
||||
'ENVI' : '',
|
||||
'GMT' : '.grd',
|
||||
'GRIB' : '.grb',
|
||||
'JPEG' : '.jpg',
|
||||
'PNG' : '.png',
|
||||
}
|
||||
|
||||
|
||||
##############################################################################
|
||||
def cmdLineParse():
|
||||
parser = argparse.ArgumentParser(description='convert the UTM geotiff to geography geotiff.',\
|
||||
formatter_class=argparse.RawTextHelpFormatter,\
|
||||
epilog=INTRODUCTION+'\n'+EXAMPLE)
|
||||
|
||||
parser.add_argument('origin', help='Name of origin hdf5 file .')
|
||||
parser.add_argument('target', help='Name of target geotiff.')
|
||||
#parser.add_argument('subdataset', help='the master date and slave date of the dataset')
|
||||
inps = parser.parse_args()
|
||||
return inps
|
||||
|
||||
|
||||
INTRODUCTION = '''
|
||||
-------------------------------------------------------------------
|
||||
create_files for psokinv software running file by generated by Gamma
|
||||
'''
|
||||
|
||||
EXAMPLE = """Usage:
|
||||
|
||||
geotiff_utm2geo.py A.h5 result.tif 20210101_20240302
|
||||
-------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
||||
inps = cmdLineParse()
|
||||
origin_tif = inps.origin
|
||||
target_tif = inps.target
|
||||
#dateset = inps.subdataset
|
||||
ftype = readfile.read_attribute(origin_tif)['FILE_TYPE']
|
||||
if ftype == 'timeseries' or ftype == 'ifgramStack':
|
||||
call_str = 'save_gdal.py ' + origin_tif + ' -d ' + target_tif +' --of GTiff -o tmp.tif '
|
||||
os.system(call_str)
|
||||
else:
|
||||
call_str = 'save_gdal.py ' + origin_tif +' --of GTiff -o tmp.tif '
|
||||
os.system(call_str)
|
||||
call_str = ' gdalwarp tmp.tif ' + target_tif + '.tif' + ' -t_srs "EPSG:4326" '
|
||||
os.system(call_str)
|
||||
call_str = 'gdal_translate -of GSBG ' + target_tif + '.tif ' + target_tif + '.grd'
|
||||
os.system(call_str)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[:])
|
||||
Reference in New Issue
Block a user