热门标签 | HotTags
当前位置:  开发笔记 > 开放平台 > 正文

ENVI二次开发时调用决策树的方法

决策树方法是一种常用的分类方法,由于ENVI没有提供自带的决策树调用接口,本文介绍如何通过安装决策树sav文件在ENVI二次开发中调用决策树接口。1.安装通过百度网盘下载sav文件

决策树方法是一种常用的分类方法,由于ENVI没有提供自带的决策树调用接口,本文介绍如何通过安装决策树sav文件在ENVI二次开发中调用决策树接口。


1.安装

通过百度网盘下载sav文件及示例代码。

链接:https://pan.baidu.com/s/1P4EQ-KjGpw9chspfRs4krw 
提取码:envi 


2.调用

  1. 将batch_decision_tree.sav拷贝到:C:\Program Files\Harris\ENVI5x\classic\save_add;

  2. 修改示例代码中,tree_file,ndvi_file及slope_file文件路径,运行示例代码;

     

    pro test_batch_dtree
    compile_opt idl2

    ENVI, /restore_base_save_files
    ENVI_BATCH_INIT
    ;Supply existing decision tree text file
    tree_file = 'D:\decision_tree_ndvi_slope.txt'
    ;Open relevant image files
    ndvi_file = 'C:\Program Files\Harris\ENVI56\classic\data\bhtmref.img'
    slope_file = 'C:\Program Files\Harris\ENVI56\classic\data\bhdemsub.img'
    envi_open_file, ndvi_file, r_fid = ndvi_fid
    envi_open_file, slope_file, r_fid = slope_fid
    ;Build arrays of tree variables, input file ids, and band positions
    ;Order is crucial. The first file id and band position array are tied to the first variable, and so on....
    ;Band positions for each file, as listed in the decision tree text file under "file pos", are 1-based. Input to this routine is zero-based, so
    ;be sure to account for that. Example: file pos = 4,3 -> pos = [3,2]. Because the number of bands can vary for each variable, they
    ;must be stored in a structure variable.
    var_names = ['ndvi','slope']
    in_fids = [ndvi_fid, slope_fid]
    pos_struct = {ndvi:[3,2], slope:[0]}
    ;Specify an output filename
    out_file = 'D:\batch_dt_test.img'
    ;Specify which input image to use as the base, along with the spatial dimensions to operate on
    base_fid = ndvi_fid
    envi_file_query, base_fid, dims=base_dims
    ;Specify an interpolation method for resizing the imagery involved. Required, even if not used in the decision process.
    ;Options are:
    ;
    ;0 - Nearest Neighbor
    ;1 - Bilinear
    ;2 - Cubic Convolution
    ;
    ;0 is always the safest option. If interpolation isn't required, the specified value is ignored.
    interp = 2
    ;Call the batch routine. Result should show up in the ABL
    batch_decision_tree, tree_file=tree_file, in_fids=in_fids, pos_struct=pos_struct, var_names=var_names, out_file=out_file, $
    base_fid=base_fid, base_dims=base_dims, interp=interp, r_fid=r_fid
    end



3.结果



推荐阅读
author-avatar
ciaos
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有