def read_band(self, band): if self.name.find('LE7') != -1: fname = self.name + '_B' + str(band / 10) + '.TIF' else: fname = self.name + '_z54_nn' + str(band) + '.tif' gt, wkt, image = pr.read_tif(fname) self.image = image
def read_band(self,band): if self.name.find('LE7') !=-1 : fname=self.name+'_B'+str(band/10)+'.TIF' else: fname=self.name+'_z54_nn'+str(band)+'.tif' gt,wkt,image=pr.read_tif(fname) self.image=image
def __init__(self,fname): self.name=fname if fname.find('LE7') != -1: f=open(fname+'_MTL.txt','r') else: f=open(fname+'.met','r') lines=f.readlines() f.close() lmax=[] lmin=[] for line in lines: if line.find('SUN_AZIMUTH') != -1: self.sun_az=float(line.split()[2]) if line.find('SUN_ELEVATION') != -1: self.sun_el=float(line.split()[2]) if line.find('LMAX_BAND1') != -1 or line.find('MAXIMUM_BAND_1') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND1') != -1 or line.find('MINIMUM_BAND_1') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND2') != -1 or line.find('MAXIMUM_BAND_2') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND2') != -1 or line.find('MINIMUM_BAND_2') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND3') != -1 or line.find('MAXIMUM_BAND_3') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND3') != -1 or line.find('MINIMUM_BAND_3') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND4') != -1 or line.find('MAXIMUM_BAND_4') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND4') != -1 or line.find('MINIMUM_BAND_4') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND5') != -1 or line.find('MAXIMUM_BAND_5') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND5') != -1 or line.find('MINIMUM_BAND_5') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND7') != -1 or line.find('MAXIMUM_BAND_7') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND7') != -1 or line.find('MINIMUM_BAND_7') != -1: lmin.append(float(line.split()[2])) self.offset=lmin[0:6] self.gain=[(x-y)/255.0 for (x,y) in zip(lmax[0:6],lmin[0:6])] if self.name.find('LE7') !=-1 : fname=self.name+'_B1.TIF' else: fname=self.name+'_z54_nn10.tif' gt,wkt,image=pr.read_tif(fname) self.image=image self.jmax,self.imax=image.shape self.xs=gt[0] self.ye=gt[3] self.dx=gt[1] self.dy=-gt[5] self.pc=self.imax/2.0 self.lc=self.jmax/2.0 self.xc=self.xs+self.dx*self.pc self.yc=self.ye-self.dy*self.lc self.t0=0.0 self.angle=0.0 self.hsat=691650.00
else: dx=0.0 dy=0.0 if os.path.isdir(fnew) == False: os.mkdir(fnew) ''' fscene='ALAV2A017062800_20060521' fname='dem.tif' fnew='NEW' dx=0.0 dy=0.0 ''' gt,wkt,dem=pr.read_tif(fname) ymax,xmax=dem.shape pr.xs=gt[0] pr.dx=gt[1] pr.xe=gt[0]+xmax*gt[1] pr.ye=gt[3] pr.dy=-gt[5] pr.ys=gt[3]-ymax*gt[5] print gt print dem.shape,dem.dtype print xmax,ymax os.chdir(fscene) sname=fscene.split('_')[0]
def __init__(self, fname): self.name = fname if fname.find('LE7') != -1: f = open(fname + '_MTL.txt', 'r') else: f = open(fname + '.met', 'r') lines = f.readlines() f.close() lmax = [] lmin = [] for line in lines: if line.find('SUN_AZIMUTH') != -1: self.sun_az = float(line.split()[2]) if line.find('SUN_ELEVATION') != -1: self.sun_el = float(line.split()[2]) if line.find('LMAX_BAND1') != -1 or line.find( 'MAXIMUM_BAND_1') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND1') != -1 or line.find( 'MINIMUM_BAND_1') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND2') != -1 or line.find( 'MAXIMUM_BAND_2') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND2') != -1 or line.find( 'MINIMUM_BAND_2') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND3') != -1 or line.find( 'MAXIMUM_BAND_3') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND3') != -1 or line.find( 'MINIMUM_BAND_3') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND4') != -1 or line.find( 'MAXIMUM_BAND_4') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND4') != -1 or line.find( 'MINIMUM_BAND_4') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND5') != -1 or line.find( 'MAXIMUM_BAND_5') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND5') != -1 or line.find( 'MINIMUM_BAND_5') != -1: lmin.append(float(line.split()[2])) if line.find('LMAX_BAND7') != -1 or line.find( 'MAXIMUM_BAND_7') != -1: lmax.append(float(line.split()[2])) if line.find('LMIN_BAND7') != -1 or line.find( 'MINIMUM_BAND_7') != -1: lmin.append(float(line.split()[2])) self.offset = lmin[0:6] self.gain = [(x - y) / 255.0 for (x, y) in zip(lmax[0:6], lmin[0:6])] if self.name.find('LE7') != -1: fname = self.name + '_B1.TIF' else: fname = self.name + '_z54_nn10.tif' gt, wkt, image = pr.read_tif(fname) self.image = image self.jmax, self.imax = image.shape self.xs = gt[0] self.ye = gt[3] self.dx = gt[1] self.dy = -gt[5] self.pc = self.imax / 2.0 self.lc = self.jmax / 2.0 self.xc = self.xs + self.dx * self.pc self.yc = self.ye - self.dy * self.lc self.t0 = 0.0 self.angle = 0.0 self.hsat = 691650.00
import cv2 import convert_util as ut import proj_util as pr param = sys.argv if len(param) != 3: print 'Usage: displacement.py scene_name dem.tif' exit() fscene = param[1] fname = param[2] #fscene='ELP108R032_7T20020630' #fname='new_utm.txt' gt, wkt, dem = pr.read_tif(fname) ymax, xmax = dem.shape pr.xs = gt[0] pr.dx = gt[1] pr.xe = gt[0] + xmax * gt[1] pr.ye = gt[3] pr.dy = -gt[5] pr.ys = gt[3] - ymax * gt[5] #fold='ELP108R032_7T20020630' os.chdir(fscene) list = os.listdir('.') for name in list: if name.find('.met') != -1: fname = name[:-4]
def __init__(self, fname): self.name = fname f = open(fname + 'MTL.txt', 'r') lines = f.readlines() f.close() #gain = np.zeros(11,dtype='float32') #offset = np.zeros(11,dtype='float32') gain = [] offset = [] for line in lines: if line.find('CORNER_UL_PROJECTION_X_PRODUCT') != -1: ULX = float(line[36:]) if line.find('CORNER_UL_PROJECTION_Y_PRODUCT') != -1: ULY = float(line[36:]) if line.find('CORNER_UR_PROJECTION_X_PRODUCT') != -1: URX = float(line[36:]) if line.find('CORNER_UR_PROJECTION_Y_PRODUCT') != -1: URY = float(line[36:]) if line.find('CORNER_LL_PROJECTION_X_PRODUCT') != -1: LLX = float(line[36:]) if line.find('CORNER_LL_PROJECTION_Y_PRODUCT') != -1: LLY = float(line[36:]) if line.find('CORNER_LR_PROJECTION_X_PRODUCT') != -1: LRX = float(line[36:]) if line.find('CORNER_LR_PROJECTION_Y_PRODUCT') != -1: LRY = float(line[36:]) if line.find('REFLECTIVE_LINES') != -1: jmax = int(line.split()[2]) if line.find('REFLECTIVE_SAMPLES') != -1: imax = int(line.split()[2]) if line.find('SUN_AZIMUTH') != -1: self.sun_az = float(line.split()[2]) if line.find('SUN_ELEVATION') != -1: self.sun_el = float(line.split()[2]) if line.find('RADIANCE_MULT_BAND_1 ') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_2') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_3') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_4') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_5') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_6') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_7') != -1: gain.append(float(line.split()[2])) #if line.find('RADIANCE_MULT_BAND_8') != -1: #gain[7]=float(line.split()[2]) if line.find('RADIANCE_MULT_BAND_9') != -1: gain.append(float(line.split()[2])) #if line.find('RADIANCE_MULT_BAND_10') != -1: #gain[9]=float(line.split()[2]) #if line.find('RADIANCE_MULT_BAND_11') != -1: #gain[10]=float(line.split()[2]) if line.find('RADIANCE_ADD_BAND_1 ') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_2') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_3') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_4') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_5') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_6') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_7') != -1: offset.append(float(line.split()[2])) #if line.find('RADIANCE_ADD_BAND_8') != -1: #offset[7]=float(line.split()[2]) if line.find('RADIANCE_ADD_BAND_9') != -1: offset.append(float(line.split()[2])) #if line.find('RADIANCE_ADD_BAND_10') != -1: #offset[9]=float(line.split()[2]) #if line.find('RADIANCE_ADD_BAND_11') != -1: #offset[10]=float(line.split()[2]) print ULX, ULY, URX, URY, LLX, LLY, LRX, LRY print imax, jmax print(URX - ULX) / (imax - 1) # 30.0 print(ULY - LLY) / (jmax - 1) # 30.0 self.gain = gain self.offset = offset fname = self.name + 'B1.tif' gt, wkt, image = pr.read_tif(fname) self.image = image self.jmax, self.imax = image.shape self.xs = gt[0] self.ye = gt[3] self.dx = gt[1] self.dy = -gt[5] self.pc = self.imax / 2.0 self.lc = self.jmax / 2.0 self.xc = self.xs + self.dx * self.pc self.yc = self.ye - self.dy * self.lc self.t0 = 0.0 self.angle = 0.0 self.hsat = 691650.00
def read_band(self, band): fname = self.name + 'B' + str(band) + '.tif' gt, wkt, image = pr.read_tif(fname) self.image = image
def __init__(self,fname): self.name=fname f=open(fname+'MTL.txt','r') lines=f.readlines() f.close() #gain = np.zeros(11,dtype='float32') #offset = np.zeros(11,dtype='float32') gain=[] offset=[] for line in lines: if line.find('CORNER_UL_PROJECTION_X_PRODUCT') != -1: ULX= float(line[36:]) if line.find('CORNER_UL_PROJECTION_Y_PRODUCT') != -1: ULY = float(line[36:]) if line.find('CORNER_UR_PROJECTION_X_PRODUCT') != -1: URX= float(line[36:]) if line.find('CORNER_UR_PROJECTION_Y_PRODUCT') != -1: URY= float(line[36:]) if line.find('CORNER_LL_PROJECTION_X_PRODUCT') != -1: LLX= float(line[36:]) if line.find('CORNER_LL_PROJECTION_Y_PRODUCT') != -1: LLY= float(line[36:]) if line.find('CORNER_LR_PROJECTION_X_PRODUCT') != -1: LRX= float(line[36:]) if line.find('CORNER_LR_PROJECTION_Y_PRODUCT') != -1: LRY= float(line[36:]) if line.find('REFLECTIVE_LINES') != -1: jmax=int(line.split()[2]) if line.find('REFLECTIVE_SAMPLES') != -1: imax=int(line.split()[2]) if line.find('SUN_AZIMUTH') != -1: self.sun_az=float(line.split()[2]) if line.find('SUN_ELEVATION') != -1: self.sun_el=float(line.split()[2]) if line.find('RADIANCE_MULT_BAND_1 ') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_2') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_3') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_4') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_5') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_6') != -1: gain.append(float(line.split()[2])) if line.find('RADIANCE_MULT_BAND_7') != -1: gain.append(float(line.split()[2])) #if line.find('RADIANCE_MULT_BAND_8') != -1: #gain[7]=float(line.split()[2]) if line.find('RADIANCE_MULT_BAND_9') != -1: gain.append(float(line.split()[2])) #if line.find('RADIANCE_MULT_BAND_10') != -1: #gain[9]=float(line.split()[2]) #if line.find('RADIANCE_MULT_BAND_11') != -1: #gain[10]=float(line.split()[2]) if line.find('RADIANCE_ADD_BAND_1 ') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_2') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_3') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_4') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_5') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_6') != -1: offset.append(float(line.split()[2])) if line.find('RADIANCE_ADD_BAND_7') != -1: offset.append(float(line.split()[2])) #if line.find('RADIANCE_ADD_BAND_8') != -1: #offset[7]=float(line.split()[2]) if line.find('RADIANCE_ADD_BAND_9') != -1: offset.append(float(line.split()[2])) #if line.find('RADIANCE_ADD_BAND_10') != -1: #offset[9]=float(line.split()[2]) #if line.find('RADIANCE_ADD_BAND_11') != -1: #offset[10]=float(line.split()[2]) print ULX,ULY,URX,URY,LLX,LLY,LRX,LRY print imax,jmax print (URX-ULX)/(imax-1) # 30.0 print (ULY-LLY)/(jmax-1) # 30.0 self.gain=gain self.offset=offset fname=self.name+'B1.tif' gt,wkt,image=pr.read_tif(fname) self.image=image self.jmax,self.imax=image.shape self.xs=gt[0] self.ye=gt[3] self.dx=gt[1] self.dy=-gt[5] self.pc=self.imax/2.0 self.lc=self.jmax/2.0 self.xc=self.xs+self.dx*self.pc self.yc=self.ye-self.dy*self.lc self.t0=0.0 self.angle=0.0 self.hsat=691650.00
def read_band(self,band): fname=self.name+'B'+str(band)+'.tif' gt,wkt,image=pr.read_tif(fname) self.image=image