在C#中通过cmd.exe调用GDAL工具实现特定功能

本文介绍了如何在C#项目中通过cmd.exe调用GDAL工具,特别是gdalwarp.exe,来实现C#内不直接支持的特定地理数据处理功能。
摘要由CSDN通过智能技术生成

我们在C#中使用GDAL时,某些功能并不能像C++那样应有尽有,甚至还不如Python那么好用,因此要实现某些特定功能,可能就要迫不得已地通过cmd.exe调用GDAL工具,下以调用gdalwarp.exe为例,为正在C#中使用GDAL开发同行提供有益的参考。

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.UseShellExecute = false;//是否使用操作系统shell启动
process.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
process.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
process.StartInfo.RedirectStandardError = true;//重定向标准错误输出
process.StartInfo.CreateNoWindow = true;
process.Start();//启动程序
 //获取gdalward.exe路径,我这里是与dll放在一起,方便其调用相关dll
var executingAssemblyFile = new Uri(Assembly.GetExecutingAssembly().GetName().CodeBase).LocalPath;
var executingDirectory = Path.GetDirectoryName(executingAssemblyFile);
var gdalPath = Path.Combine(executingDirectory, "gdal");
var nativePath = Path.Combine(gdalPa
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值