- 积分
- 478
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-5-3
- 最后登录
- 1970-1-1

|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 sound 于 2020-4-18 12:38 编辑
由于近期正在学习C#,采用vs2015+surfer11,从网上找到调用命令,在调试过程中下列红色命令如下报错,色标文件测试可用,找了3天问题,但找不到原因(包括换调用surfer8,查了11的automation也没有得到解决)请教下各位,感谢!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using Surfer;
namespace AppSurfer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string strFolder = @"d:\AppSurfer\content";
string OutGrpahic = @"d:\AppSurfer\outrain.bmp";
private void button1_Click_1(object sender, EventArgs e)
{
string DataFile = strFolder + @"\rain.txt";
string OutGrid = strFolder + @"\grid_rain.grd";
string SmoothGrid = strFolder + @"\smooth_rain.grd";
string BlankFile = strFolder + @"\市边界.bln";
string BlankedGrid = strFolder + @"\blank_rain.grd";
string BaseFile = strFolder + @"\市底图.bln";
string PoseFile = strFolder + @"\站名.dat";
string LevelFile = strFolder + @"\rainfall.lvl";
Surfer.Application AppSurfer = new Surfer.Application(); //对Surfer的调用
AppSurfer.Visible = false; //注Surfer窗口是不显现
AppSurfer.WindowState = Surfer.SrfWindowState.srfWindowStateMinimized;
AppSurfer.Caption = "百色市雨量分布图";
AppSurfer.ScreenUpdating = false; //Surfer制图过程是否显示
AppSurfer.GridData(DataFile, 1, 2, 3, Type.Missing, Surfer.SrfDupMethod.srfDupNone, 0.03, 0.03, Type.Missing, Type.Missing,
104.3, 108.1, 22.75, 25.2, Surfer.SrfGridAlgorithm.srfKriging, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, OutGrid, Surfer.SrfGridFormat.srfGridFmtAscii,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
/*注:将所提供的降水文件格点化, DataFile即需要格点化的文件名加路径,文件第1列是经度,第2列是纬度,第3列是降水量值,网格经纬向的分
辨率都是0. 03,起始经度是104.3度,终止经度是108.1度,起始纬度是22.75度,终止纬度是25.2度,选择的插值方法是Kriging方法, GridFile即时离散插值后生
成的路径加文件名(其后缀应该是“. grd”, . grd文件格式是Ascii码的形式;*/
AppSurfer.GridSplineSmooth(OutGrid, 8, 8, SrfSplineMethod.srfSplineInsert, SmoothGrid, SrfGridFormat.srfGridFmtAscii);
/*注:OutGrid为输入的格点化文件路径加文件名,将其进行平滑,平滑方法为Insert,行列的插值点数都设为8,SmoothGrid为输出的格点化文件路径加文件
名,其输出格式也是Ascii码;*/
AppSurfer.GridBlank(SmoothGrid, BlankFile, BlankedGrid, Surfer.SrfGridFormat.srfGridFmtAscii);
/*注:第一个GridFile为输入的格点化文件路径加文件名,将其利用bln文件去掉边界外的数据,BlankedGrid为输出的格点化文件路径加文件
名,其输出格式也是Ascii码;*/
Surfer.IPlotDocument Doc = (Surfer.IPlotDocument)AppSurfer.Documents.Add(Surfer.SrfDocTypes.srfDocPlot);
//建立一个绘图文档和一个绘图窗口
Surfer.IMapFrame mapframe = Doc.Shapes.AddContourMap(BlankedGrid);
//注:添加等值面图层MapFrame,将BlankedGrid格点化文件生成等值线图;
mapframe.Axes.Item(1).Visible = false;
mapframe.Axes.Item(2).Visible = false;
mapframe.Axes.Item(3).Visible = false;
mapframe.Axes.Item(4).Visible = false;
//注:不显示标注图的横纵坐标轴
Surfer.IContourMap ClassedCounterMap = (Surfer.IContourMap)mapframe.Overlays.Item(1);
//注:将等值线图形属性指定给变量ClassedCounterMap;
ClassedCounterMap.Levels.LoadFile(LevelFile); //注:等值线图的色彩填充文件为LevelFile,
ClassedCounterMap.FillContours = true; //绘制等值线;
ClassedCounterMap.ShowColorScale = true; //显示色标条;
ClassedCounterMap.SmoothContours = SrfConSmoothType.srfConSmoothHigh; //SmoothContours为平滑等值线边界
报错显示:未处理COMExceptiong “System.Runtime.InterServices.COMExceptiong”类型的未经处理的异常在SurferDemo.exe中发生
其他信息:服务器出现意外情况,(异常来自 HRESULT:0x80010105(RPC_E_SERVERFALT))
|
|