什么是foat文件,当我想实现浮动到栅格功能时如何打开文件? [英] What is a foat file and how can i open one when I want to realize the function float to raster?

查看:134
本文介绍了什么是foat文件,当我想实现浮动到栅格功能时如何打开文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于定制实现ArcGIS Web服务.我已经构建了一个Web服务,该服务将实现ArcTools中名为FloatToRaster的功能之一.我的代码如下:

I''m realizeing ArcGIS webservices based on customization. I have built a webservice which is to realize one of the functions in ArcTools named FloatToRaster. My code is as belows:

[WebMethod]
public string ConversionTools_FloatToRaster(string string_inFloat, string string_outRaster)
{
    ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
    ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeArcInfo);

    //IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
    //IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(string_inFloat), 0);
    //IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
    //IFeatureDataset pFeatureClass = pFeatureWorkspace.OpenFeatureDataset(System.IO.Path.GetFileNameWithoutExtension(string_inFloat));
    //FloatToRaster flt = new FloatToRaster();
    //flt.in_float_file();
    ////IRasterDataset pRasterDataset = pWorkspace(System.IO.Path.GetFileNameWithoutExtension(string_inFloat));
    //public string in_float_file
    //{
    //    get{return string_inFloat;}
    //}

    String outDict = System.IO.Path.GetDirectoryName(string_inFloat);
    String outRaster = outDict + "\\" + string_outRaster;

    ESRI.ArcGIS.ConversionTools.FloatToRaster floatToRaster = new ESRI.ArcGIS.ConversionTools.FloatToRaster(string_inFloat, outRaster);//<big>The Problem Line</big>

    ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new Geoprocessor();
    ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult results = (ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult)gp.Execute(floatToRaster, null);

    string returnString = outRaster;
    if (results.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded)
    {
        returnString = "Fail Changing!";
    }
    return returnString;
}



string_inFloat是浮动文件的文件路径.
这是"FloatToRaster"的定义:



string_inFloat is the file path of a float file.
Here is the definition of ''FloatToRaster'':

namespace ESRI.ArcGIS.ConversionTools
{
    //     Converts a file of binary floating-point values representing raster data
    //     to a raster dataset.
    public class FloatToRaster : IGPProcess
    {
        public FloatToRaster();
        //     Constructor that takes all required parameters for geoprocessor execution.
        //
        // parameter:
        //   in_float_file:
        //     The input floating-point binary file. The file must have a .flt extension.
        //     There must be a header file in association with the floating-point binary
        //     file, with a .hdr extension. (In, Required)
        //
        //   out_raster:
        //     The raster dataset to be created. (Out, Required)
        public FloatToRaster(object in_float_file, object out_raster);
    }





当我测试程序时,错误显示如下:





When I test the program, the Error shows as below:

System.NullReferenceException: object reference is not set to an instant of an object.
   The problem is at <big>ToRaster.FloatToRaster(String string_inFloat, String string_outRaster)</big>  f:\ConversionTools\App_Code\ToRaster.cs:Line 225




问题是参数string_inFloat.
似乎"string_inFloat"参数不适合FloatToRaster(object inputFloat,object outRaster)方法.
因此,我想知道如何打开浮动文件!




The problem is the parameter string_inFloat.
It seems that the ''string_inFloat'' parameter doesn''t fit the FloatToRaster(object inputFloat, object outRaster) Method.
So I want to know HOW I COULD OPEN A FLOAT FILE!

推荐答案

正如xcorporation所述,尽管可以做得更好,但是请更改此行;
As xcorporation mentioned, though it could have been done better, change this line;
ESRI.ArcGIS.ConversionTools.FloatToRaster floatToRaster = new FloatToRaster(string_inFloat, outRaster);


阅读;


to read;

ESRI.ArcGIS.ConversionTools.FloatToRaster floatToRaster = new ESRI.ArcGIS.ConversionTools.FloatToRaster(string_inFloat, outRaster);


尝试创建ESRI.ArcGIS.ConversionTools.FloatToRaster类的实例时,您可能会发现编译器正在将ESRI.ArcGIS.ConversionTools.FloatToRaster类与FloatToRaster函数混淆.


You may find the compiler is confusing the ESRI.ArcGIS.ConversionTools.FloatToRaster class with your FloatToRaster function when you''re trying to create an instance of the ESRI.ArcGIS.ConversionTools.FloatToRaster class.


您好,

公共字符串FloatToRaster(字符串string_inFloat,字符串string_outRaster)
{
//代码详细信息

ESRI.ArcGIS.ConversionTools.FloatToRaster floatToRaster =新的FloatToRaster(string_inFloat,outRaster);//问题线

}

您正在造成sh * t,因为您的方法进入了无限循环.

还有,
如果您想出去"使用类似

Hi,

public string FloatToRaster(string string_inFloat, string string_outRaster)
{
// Code Details

ESRI.ArcGIS.ConversionTools.FloatToRaster floatToRaster = new FloatToRaster(string_inFloat, outRaster);//The Problem Line

}

You are causing sh*t because your method goes into a infinite loop.

Also,
if you want "out" use something like

public string FloatToRaster(string string_inFloat, out string string_outRaster)
{



问候,
克里斯



Regards,
Chris


字符串或字符串-与字段名称无关

使用适当的命名约定将避免将来出现头痛.

修复无限循环.

:omg:
a string si a string - irrelevant of the field''s name

using a proper naming convention will avoid headache''s in the future.

fix your infinite loop.

:omg:


这篇关于什么是foat文件,当我想实现浮动到栅格功能时如何打开文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆