• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

gisoracle

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

ArcGIS Pro二次开发-获得一个栅格

/// <summary>

        /// Open a Raster Dataset given a folder and a dataset name.

        /// </summary>

        /// <param name="folder">Full path to the folder containing the raster dataset.</param>

        /// <param name="name">Name of the raster dataset to open.</param>

        /// <returns></returns>

        public static RasterDataset OpenRasterDataset(string folder, string name)

        {

            // Create a new raster dataset which is set to null

            RasterDataset rasterDatasetToOpen = null;

            try

            {

                // Create a new file system connection path to open raster datasets using the folder path.

                FileSystemConnectionPath connectionPath = new FileSystemConnectionPath(new System.Uri(folder), FileSystemDatastoreType.Raster);

                // Create a new file system data store for the connection path created above.

                FileSystemDatastore dataStore = new FileSystemDatastore(connectionPath);

                // Open the raster dataset.

                rasterDatasetToOpen = dataStore.OpenDataset<RasterDataset>(name);

                // Check if it is not null. If it is show a message box with the appropriate message.

                if (rasterDatasetToOpen == null)

                    MessageBox.Show("Failed to open raster dataset: " + name);

            }

            catch (Exception exc)

            {

                // If an exception occurs, show a message box with the appropriate message.

                MessageBox.Show("Exception caught in OpenRasterDataset for raster: " + name + exc.Message);

            }

            return rasterDatasetToOpen;

        }

 

posted on 2020-03-12 11:24  gisai  阅读(325)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3