GDAL生成等高线——等值线

本文主要介绍:利用gdal的函数,根据DEM图像,生成等高线或等值线,介绍两种方法:一种是利用GDAL自带的exe文件,一种是利用GDAL函数。

说明:GDAL使用版本为Gdal2.0.0。

1 利用GDAL自带exe,生成等高线

1.1 参数说明
具体说明可见:GDAL实用工具简介
官网说明:gdal_contour.exe

1.2 调用exe程序

//数字 转 string
string Float2String(float num, string format)
{
    char temp[100];
    sprintf_s(temp, format.c_str(), num);//保留2位小数
    string str = temp;

    return str;
}

/********************************************************************
    函数功能:调用gdal自带exe生成等高线
    输入参数:
            imgPath             :dem文件路径
            shpPath             :等高线矢量图保存路径
            dfContourInterval   :等高线间隔

    备注:
        需要头文件: #include <windows.h>

*********************************************************************/
bool CalContourByExe(string imgPath, string shpPath, double dfContourInterval)
{
    string temp = "gdal_contour.exe -a Height "; //海拔高度对应的字段名为Height 也可以改为其它名字
    temp = imgPath + " " + shpPath + " " + "-i " + Float2String(dfContourInterval, "%.1f");;

    STARTUPINFO si;
    memset(&si,0,sizeof(STARTUPINFO));//初始化si在内存块中的值(详见memset函数)
    si.cb=sizeof(STARTUPINFO);
    si.dwFlags=STARTF_USESHOWWINDOW;
    si.wShowWindow=SW_SHOW;
    PROCESS_INFORMATION pi;//必备参数设置结束


    WCHAR wcharTemp[
  • 5
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值