A feature class or table can have a raster attribute field to store any raster related to the feature. You can edit raster values in the raster field using the Editor tool. If you have many raster datasets to add to the raster field, you need to write a custom application to simplify the workflow.

Loading a raster dataset to the raster field in a feature class

To load a raster dataset to the raster field, follow these steps:
  1. Get a workspace for editing.
  2. Find the raster field index.
  3. Create a raster value object with an input raster dataset.
  4. Set the raster value to the raster field.
  5. Stop editing and save.
The following code sample shows how to load a raster dataset into a feature in a feature class given the ObjectID (OID) of the feature. Only geodatabase feature classes can have a raster attribute field.

[C#]

static void LoadToRasterAttribute(IFeatureClass featureClass, IRasterDataset
rasterDataset, int OID)
{
/*Parameters:
featureClass—The feature class with raster attribute.
rasterDataset—The raster dataset to be loaded to the raster attribute.
OID—The ObjectID of the feature to be edited.
*/ //Get workspace for editing.
IDataset dataset = (IDataset)featureClass;
IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)dataset.Workspace;
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
IFeature feature = featureClass.GetFeature(OID); //Find raster field index.
int iRasterField = 0;
for (int i = 0; i < feature.Fields.FieldCount; i++)
{
if (feature.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeRaster)
{
iRasterField = i;
i = 1000;
}
} //Create raster value with input raster dataset.
IRasterValue rasterValue = new RasterValueClass();
rasterValue.RasterDataset = rasterDataset; //Set raster value to the raster field.
feature.set_Value(iRasterField, rasterValue);
feature.Store(); //Stop editing and save edits.
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
}

[VB.NET]

Public Sub LoadToRasterAttribute(ByVal featureClass As IFeatureClass, ByVal rasterDataset As IRasterDataset, ByVal OID As Integer) ' Parameters:
' featureClass—The feature class with raster attribute.
' rasterDataset—The raster dataset to be loaded to the raster attribute.
' OID—The ObjectID of the feature to be edited. 'Get workspace for editing.
Dim dataset As IDataset = CType(featureClass, IDataset)
Dim workspaceEdit As IWorkspaceEdit = CType(dataset.Workspace, IWorkspaceEdit)
workspaceEdit.StartEditing(False)
workspaceEdit.StartEditOperation() Dim feature As IFeature = featureClass.GetFeature(OID)
'Find raster field index.
Dim iRasterField As Integer = 0
Dim i As Integer
For i = 0 To feature.Fields.FieldCount - 1 Step i + 1
If feature.Fields.get_Field(i).Type = esriFieldType.esriFieldTypeRaster Then
iRasterField = i
i = 1000
End If
Next 'Create raster value with input raster dataset.
Dim rasterValue As IRasterValue = New RasterValueClass()
rasterValue.RasterDataset = rasterDataset 'Set raster value to the raster field.
feature.set_Value(iRasterField, rasterValue)
feature.Store() 'Stop editing and save edits.
workspaceEdit.StopEditOperation()
workspaceEdit.StopEditing(True)
End Sub


To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):

Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine

How to load a raster dataset to the raster field in a feature class的更多相关文章

  1. ArcEngine和GDAL读写栅格数据机制对比(二)—— IPixelBlock读写栅格

    以下是设定一个矩形框,用IPixelBlock将256*256瓦片tile拼接成一个整块影像的代码,row1, col1, row2, col2是一个矩形框行列号范围.level是瓦片的金字塔等级.这 ...

  2. esriFeatureType与esriGeometryType的区别与联系

    esriFeatureType通常用来表示数据的存储结构,即物理层: esriGeometryType通常用来表示数据的几何形状,即表现层. esriGeometryType枚举类型详解 常量 值 对 ...

  3. Regression:Generalized Linear Models

    作者:桂. 时间:2017-05-22  15:28:43 链接:http://www.cnblogs.com/xingshansi/p/6890048.html 前言 本文主要是线性回归模型,包括: ...

  4. 机器学习算法整理(一)线性回归与梯度下降 python实现

    回归算法 以下均为自己看视频做的笔记,自用,侵删! 一.线性回归 θ是bias(偏置项) 线性回归算法代码实现 # coding: utf-8 ​ get_ipython().run_line_mag ...

  5. Generalized Linear Models

    作者:桂. 时间:2017-05-22  15:28:43 链接:http://www.cnblogs.com/xingshansi/p/6890048.html 前言 主要记录python工具包:s ...

  6. ArcEngine和GDAL读写栅格数据机制对比(一)

    最近应用AE开发插值和栅格转等值线的程序,涉及到栅格读写的有关内容.联想到ArcGIS利用了GDAL的某些东西,从AE的OMD中也发现RasterDataset和RasterBand这些命名和GDAL ...

  7. 吴裕雄--天生自然 python数据分析:健康指标聚集分析(健康分析)

    # This Python 3 environment comes with many helpful analytics libraries installed # It is defined by ...

  8. 深度学习原理与框架-神经网络-cifar10分类(代码) 1.np.concatenate(进行数据串接) 2.np.hstack(将数据横着排列) 3.hasattr(判断.py文件的函数是否存在) 4.reshape(维度重构) 5.tanspose(维度位置变化) 6.pickle.load(f文件读入) 7.np.argmax(获得最大值索引) 8.np.maximum(阈值比较)

    横1. np.concatenate(list, axis=0) 将数据进行串接,这里主要是可以将列表进行x轴获得y轴的串接 参数说明:list表示需要串接的列表,axis=0,表示从上到下进行串接 ...

  9. Client Dataset Basics

    文章出处:  http://www.informit.com/articles/article.aspx?p=24094 In the preceding two chapters, I discus ...

随机推荐

  1. js webapp 滑动事件

    var startX, startY, endX, endY; $(".detailImg").on("touchstart", touchStart);$(& ...

  2. 简单Bat文件编写

    @ECHO OFFTITLE 清理Work目录E:cd E:\Android_WorkSpace@ECHO ONecho 开始打包MavenTest......mvn install pause @E ...

  3. mysql中替换字符串(正则) 模糊

    例如: abcd(efg)hijk 替换之后是abcdhijk , name)),''); 执行之后,报错:Truncated incorrect DOUBLE value解决办法,经过查询发现是co ...

  4. STL中stack小结

    (1)为了运用stack,你必须包含头文件<stack>:#include<stack> (2)在头文件中stack定义如下: namespace std{ template ...

  5. Android manifest之manifest标签详细介绍

    AndroidManifest详细介绍 本文主要对AndroidManifest.xml文件中各个标签进行说明.索引如下: 概要PART--01 manifest标签PART--02 安全机制和per ...

  6. Ember Charts – 基于 Ember & D3 的图表库

    Ember Charts 是一个基于 Ember.js 和 D3.js 的图表库.它包括时间序列.柱状图.饼图.点图,很容易扩展和修改.这些图表组件代表图表交互性和演示的最佳实践,是高度可定制和可扩展 ...

  7. CentOS6.5菜鸟之旅:安装Realtek无线网卡驱动

    一.前言 CentOS6.5不像CentOS7和Unbuntu那样自动安装好了无线网卡驱动,因此需要我们折腾一下. 二.安装前的准备工作   [a] 检查无线网卡驱动的安装情况(通过查看网络接口的安装 ...

  8. C#函数式程序设计之代码即数据

    自3.5版本以来,.NET以及微软的.NET语言开始支持表达式树.它们为这些语言的某个特定子集提供了eval形式的求值功能.考虑下面这个简单的Lambda表达式: Func<int, int, ...

  9. Spring应用——事务管理

    事务基础:请参看:http://www.cnblogs.com/solverpeng/p/5720306.html 一.Spring 事务管理 1.前提:事务管理器 在使用 Spring 声明式事务管 ...

  10. .Net 配置文件——继承ConfigurationSection实现自定义处理类处理自定义配置节点

    除了使用继承IConfigurationSectionHandler的方法定义处理自定义节点的类,还可以通过继承ConfigurationSection类实现同样效果. 首先说下.Net配置文件中一个 ...