遥感IDL二次开发(光谱数据可视化)
详细信息
1.程序功能:
打开 ASCII 码格式的光谱文件,读取反射率数据并进行显示。
2.源代码:
2.1 方法1:单一窗口显示光谱数据
#在同一个窗口中用不同线形和颜色显示光谱数据#
pro IDL020101
fn=dialog_pickfile();打开光谱数据
nb=file_lines(fn)
data=fltarr(5,nb)
openr,lun,fn,/get_lun
readf,lun,data
free_lun,lun
wv=transpose(data[0,*]);读取波长
c1=transpose(data[1,*]);读取第1条光谱曲线的反射率
c2=transpose(data[2,*]);读取第2条光谱曲线的反射率
c3=transpose(data[3,*]);读取第3条光谱曲线的反射率
c4=transpose(data[4,*]);读取第4条光谱曲线的反射率
;在同一个窗口中用不同线形和颜色显示光谱数据
p1=plot(wv,c1,xtitle='Wavelength(nm)',ytitle='Reflectance',$
/buffer,xrange=[min(wv),max(wv)],color='red',linestyle=0,$
thick=1,name='spectral curve1',margin=[0.1,0.1,0.01,0.01])
p2=plot(wv,c2,xtitle='Wavelength(nm)',ytitle='Reflectance',$
/buffer,xrange=[min(wv),max(wv)],color='blue',linestyle=0,$
thick=1,name='spectral curve2',/overplot)
p3=plot(wv,c3,xtitle='Wavelength(nm)',ytitle='Reflectance',$
/buffer,xrange=[min(wv),max(wv)],color='green',linestyle=0,$
thick=1,name='spectral curve3',/overplot)
p4=plot(wv,c4,xtitle='Wavelength(nm)',ytitle='Reflectance',$
/buffer,xrange=[min(wv),max(wv)],color='orange',linestyle=0,$
thick=1,name='spectral curve4',/overplot)
;添加图例
l1=legend(target=[p1,p2,p3,p4],position=[0.6,0.2],color='w',$
/auto_text_color,horizontal_alignment=0,vertical_alignment=0,$
horizontal_spacing=0.02,vertical_spacing=0.01,/normal)
;保存文件
o_fn=dialog_pickfile(title='图形保存为')+'.png'
p1.save,o_fn,border=0
p2.save,o_fn,border=0
p3.save,o_fn,border=0
p4.save,o_fn,border=0
end
结果图:
2.2 方法2:同一个窗口中的四个子窗口显示光谱曲线
#同一个窗口中的四个子窗口显示光谱曲线#
pro IDL020102
fn=dialog_pickfile();打开光谱数据
nb=file_lines(fn)
data=fltarr(5,nb)
openr,lun,fn,/get_lun
readf,lun,data
free_lun,lun
wv=transpose(data[0,*]);读取波长
c1=transpose(data[1,*]);读取第1条光谱曲线的反射率
c2=transpose(data[2,*]);读取第2条光谱曲线的反射率
c3=transpose(data[3,*]);读取第3条光谱曲线的反射率
c4=transpose(data[4,*]);读取第4条光谱曲线的反射率
;用同一窗口中的子窗口中显示光谱曲线
x=findgen(101)*0.01
window,1,xsize=900,ysize=600
plot,wv,c1,position=[0.1,0.6,0.45,0.9],xtitle='Wavelength(nm)',ytitle='Reflectance',title='spectral curve1',$
color='000000'xl,background='FFFFFF'xl,/nodata
oplot,wv,c1,color='f00000'xl
plot,wv,c2,position=[0.6,0.6,0.95,0.9],xtitle='Wavelength(nm)',ytitle='Reflectance',title='spectral curve2',/noerase,$
color='000000'xl,background='FFFFFF'xl,/nodata
oplot,wv,c2,color='0000ff'xl
plot,wv,c3,position=[0.1,0.1,0.45,0.4],xtitle='Wavelength(nm)',ytitle='Reflectance',title='spectral curve3',/noerase,$
color='000000'xl,background='FFFFFF'xl,/nodata
oplot,wv,c3,color='00ffff'xl
plot,wv,c4,position=[0.6,0.1,0.95,0.4],xtitle='Wavelength(nm)',ytitle='Reflectance',title='spectral curve4',/noerase,$
color='000000'xl,background='FFFFFF'xl,/nodata
oplot,wv,c4,color='0fff00'xl
end
结果图:
来源引用:地理遥感生态网平台www.gisrs.cn