麻辣GIS微信平台

更多 GIS 干货

微信关注不错过

ArcGIS Engine 10 开发手册(8-17)示例:RasterConvertHelperClass 接口调用

本文演示使用ArcGIS Engine 实现 RasterConvertHelperClass 接口调用功能演示代码示例。

示例代码

public void ConvertRaterToLineFeature (string pRasterWs, string pRasterDatasetName, string pShapeFileName)

{

  IRasterDataset pRasterDataset = GetRasterWorkspace (pRasterWs).OpenRasterDataset (pRasterDatasetName);

  IConversionOp pConversionOp = new RasterConversionOpClass ();
  IRasterAnalysisEnvironment pEnv = (IRasterAnalysisEnvironment) pConversionOp;

  IWorkspaceFactory pWorkspaceFactory = new RasterWorkspaceFactoryClass ();
  IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile (pRasterWs, 0);
  pEnv.OutWorkspace = pWorkspace;

  IWorkspaceFactory pShapeFactory = new ShapefileWorkspaceFactoryClass ();

  IWorkspace pShapeWS = pShapeFactory.OpenFromFile (pRasterWs, 0);

  System.Object pDangle = (System.Object) 1.0;

  IGeoDataset pFeatClassOutput = pConversionOp.RasterDataToLineFeatureData ((IGeoDataset) pRasterDataset, pShapeWS, pShapeFileName, false, false, ref pDangle);

}

/// <summary>

/// 要素转成Grid

/// </summary>

/// <param name="pFeaureClass"></param>

/// <param name="pRasterWorkspaceFolder"></param>

/// <param name="pCellsize"></param>

/// <param name="pGridName"></param>

/// <returns></returns>

public IGeoDataset CreateGridFromFeatureClass (IFeatureClass pFeaureClass, String pRasterWorkspaceFolder, double pCellsize, string pGridName)

{

  IGeoDataset pGeoDataset = (ESRI.ArcGIS.Geodatabase.IGeoDataset) pFeaureClass; // Explicit Cast

  ISpatialReference pSpatialReference = pGeoDataset.SpatialReference;

  IConversionOp pConversionOp = new ESRI.ArcGIS.GeoAnalyst.RasterConversionOpClass ();

  IWorkspaceFactory pWorkspaceFactory = new ESRI.ArcGIS.DataSourcesRaster.RasterWorkspaceFactoryClass ();

  IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile (pRasterWorkspaceFolder, 0);

  IRasterAnalysisEnvironment pAnalysisEnvironment = (ESRI.ArcGIS.GeoAnalyst.IRasterAnalysisEnvironment) pConversionOp; // Explicit Cast

  pAnalysisEnvironment.OutWorkspace = pWorkspace;

  ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = new ESRI.ArcGIS.Geometry.EnvelopeClass ();

  pEnvelope = pGeoDataset.Extent;

  object pObjectCellSize = (System.Object) pCellsize;

  pAnalysisEnvironment.SetCellSize (ESRI.ArcGIS.GeoAnalyst.esriRasterEnvSettingEnum.es riRasterEnvValue, ref pObjectCellSize);

  object object_Envelope = (System.Object) pEnvelope;
  object object_Missing = Type.Missing;

  pAnalysisEnvironment.SetExtent (ESRI.ArcGIS.GeoAnalyst.esriRasterEnvSettingEnum.esri RasterEnvValue, ref object_Envelope, ref object_Missing);

  pAnalysisEnvironment.OutSpatialReference = pSpatialReference;

  IRasterDataset pRasterDataset = new ESRI.ArcGIS.DataSourcesRaster.RasterDatasetClass ();

  pRasterDataset = pConversionOp.ToRasterDataset (pGeoDataset, "GRID", pWorkspace, pGridName);

  IGeoDataset pGeoOutput = (ESRI.ArcGIS.Geodatabase.IGeoDataset) pRasterDataset;
  return pGeoOutput;

}

ArcGIS Engine 10 开发手册全集

ArcGIS Engine 10 开发手册全集: ArcGIS Engine 10 开发手册

相关阅读

麻辣GIS-Sailor

作者:

GIS爱好者,学GIS,更爱玩GIS。

声明

1.本文所分享的所有需要用户下载使用的内容(包括但不限于软件、数据、图片)来自于网络或者麻辣GIS粉丝自行分享,版权归该下载资源的合法拥有者所有,如有侵权请第一时间联系本站删除。

2.下载内容仅限个人学习使用,请切勿用作商用等其他用途,否则后果自负。

手机阅读
公众号关注
知识星球
手机阅读
麻辣GIS微信公众号关注
最新GIS干货
关注麻辣GIS知识星球
私享圈子

留言板(小编看到第一时间回复)