生成冰川面积统计结果

pro Part_9
  compile_opt idl2
  e=envi(/headless)
  file_mkdir,"D:\Lansat_Data_综合报告"
  glacier_all = float(0.0)
  pixel_all_69 = float(0.0)
  folder = "D:\Lansat_Data_Ratio\"
  envi_arr = file_search(folder,'*.dat',count=num)
  arr_out_put = strarr(4,70)
  for i=0,num-1,1 do begin
    envi_file = envi_arr[i]
    envi_name_length = strlen(envi_file)
    if (envi_name_length eq 26) then begin
      roi_number = strmid(envi_file,21,1)
      roi_number_int = fix(strmid(envi_file,21,1))
    endif else if (envi_name_length eq 27) then begin
      roi_number = strmid(envi_file,21,2)
      roi_number_int = fix(strmid(envi_file,21,2))
    endif
    glacier_pixel = long(0)
    raster = e.OpenRaster(envi_file)
    fid = ENVIRasterToFID(raster)
    MAP_INFO = ENVI_GET_MAP_INFO(fid=fid)
    ENVI_FILE_QUERY, fid, ns=ns, nl=nl, nb=nb, dims=dim, data_type=data_type
    data = raster.getdata()
    for l=0,ns-1,1 do begin
      for m=0,nl-1,1 do begin
        a=data[l,m]
        if (a eq 1) then begin
          glacier_pixel = glacier_pixel + 1
        endif
      endfor
    endfor
    glacier_all = glacier_all + glacier_pixel
    all_pixel = long(ns)*nl
    pixel_all_69 = pixel_all_69 + all_pixel
    percentage = (float(glacier_pixel)/all_pixel)*100
    arr_out_put[0,roi_number_int-1] = roi_number;ROI序号
    arr_out_put[1,roi_number_int-1] = string(all_pixel);总像素量
    arr_out_put[2,roi_number_int-1] = string(glacier_pixel);冰川像素
    arr_out_put[3,roi_number_int-1] = string(percentage);冰川百分比
    print,envi_file
  endfor
  percentage_final = (glacier_all/pixel_all_69)*100
  arr_out_put[0,69] = "ALL-ROI"
  arr_out_put[1,69] = string(pixel_all_69);总像素量
  arr_out_put[2,69] = string(glacier_all);冰川像素
  arr_out_put[3,69] = string(percentage_Final);冰川百分比
  txt_file = "D:\Lansat_Data_综合报告\glacier_report.txt"
  openw,lun,txt_file,/get_lun
  printf,lun,arr_out_put
  free_lun,lun
  print,"----------------------OK!!!-----------------------------"
  print,txt_file
end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值