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 开发手册

如果本文对你有所帮助,欢迎对我们团队进行打赏捐助,让我们在传播3S的路上可以走得更远。
赞赏支持
微信捐助麻辣GIS 支付宝捐助麻辣GIS

麻辣GIS-Sailor
作者:
GIS爱好者,学GIS,更爱玩GIS。

如您有疑问,可在文末留言,也可在 麻辣GIS•小分队 搜索回答或发帖 ,还可以在QQ群中提问。

本站QQ群(一):291616564 麻辣GIS

本站QQ群(二):166408035 麻辣GIS(二)

微信公众号:malagis,扫描右边二维码直接关注。

发表评论