ArcGis 字段计算器表达式(Field calculator expression).cal文件的实质及其编码方式...

ArcGis 字段计算器表达式可以保存为一个扩展名为.cal的文件,该文件的实质是一个文本文件,编码方式为 UTF-16-LE。

官方的说明是“ArcGIS 应用程序使用 UTF-16-LE 编码读写 .cal 文件。只要输出使用 UTF-16-LE 编码编写,其他应用程序(如记事本)可用于创建或修改 .cal 文件。使用任何其他编码将导致文件无法加载到代码段中。

在记事本编辑后保存时编码方式应选用Unicode。

在.net中读写应使用Encoding.Unicode。

例:

 1  string saveFilePath = Utils.PathUtil.ShowSaveFileDialog("ArcGis字段计算器表达式|*.cal|所有文件|*.*", ".cal");
 2                 if (saveFilePath != string.Empty)
 3                 {
 4                     StringBuilder stringBuilder = new StringBuilder();
 5                     stringBuilder.Append(this.rtxtCode.Text);
 6                     stringBuilder.AppendLine();
 7                     stringBuilder.Append("__esri_field_calculator_splitter__");
 8                     stringBuilder.AppendLine();
 9                     stringBuilder.Append(this.rtxtFunctionName.Text);
10                     System.IO.FileStream fileStream = new System.IO.FileStream(saveFilePath, FileMode.Create);
11                     StreamWriter streamWriter = new StreamWriter(fileStream,Encoding.Unicode);
12                     streamWriter.Write(stringBuilder);
13                     streamWriter.Flush();
14                     streamWriter.Close();
15                     streamWriter.Dispose();
16                     fileStream.Close();
17                 }

 编码方式自官方说明得之,链接附此:

https://pro.arcgis.com/zh-cn/pro-app/tool-reference/data-management/calculate-field.htm

转载于:https://www.cnblogs.com/yzhyingcool/p/11182220.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值