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. Qt lcdNumber 不能显示完整时间

    利用lcdNumber编了一个电子时钟,发现只显示“分”和“秒”,“时”没有显示出来.作为小白一名,谷歌了一下别人的程序才知道,原因是没有设置lcdNumber可以显示的位数,默认应该是显示4位的,所 ...

  2. [原]Android打包之跨平台打包

    Android自动打包流程详细图: 在前面一些博客我们知道了如何通过命令行打包,如何通过Eclipse打包,如何通过编写shell脚本来进行打包,但是这些都不能很好的跨平台进行打包. 因Python本 ...

  3. java笔试练习题

    选择题(共50题,每题1.5分,共75分.多选题选不全或选错都不得分.)1. 以下属于面向对象的特征的是(C,D).(两项)A) 重载B) 重写C) 封装D) 继承 2. 以下代码运行输出是(C)pu ...

  4. Java知多少(108)数据库查询简介

    利用Connection对象的createStatement方法建立Statement对象,利用Statement对象的executeQuery()方法执行SQL查询语句进行查询,返回结果集,再形如g ...

  5. Log4Net 手册

    首先感慨下,现在的程序员做的工作因为高级语言的生产力,系统框架模式的成熟,开源大牛的贡献,已经成越来越偏向 “面向配置编程”了...... 详细使用指南见文章:http://blog.csdn.net ...

  6. WCF小白初试 错误之一:“有零个应用程序终结点”的解决办法

    遇到这类问题 应该是配置文件出现了问题 解决办法是将配置文件中的<service name="命名空间+类名">就可以解决

  7. jQuery的maskedinput插件 设置input掩码

    一.下载插件  http://digitalbush.com/projects/masked-input-plugin/二.属性a: 表示只能输入大小写字母9:表示只能输入0-9之间的数字*:a和9的 ...

  8. SQL Server 2008 各种DateTime的取值范围

    SQL Server 2008除了DateTime和SmallDateTime之外,又新增了四种时间类型,分别为:date,time,datetime2和datetimeoffset. 各时间类型范围 ...

  9. App.js – 用于移动 Web App 开发的 JS 界面库

    App.js 是一个轻量级的 JavaScript UI 库,用于创建像本地应用程序的移动 Web 应用而不牺牲性能和体验.它是跨平台的,特定的UI设计,配置类似原生的过渡效果.App.js 的目的是 ...

  10. 一个ListView布局的不断演化

    刚出来工作,就负责一个APP的某块功能的编写,该功能就是类似微博那样的界面.微博界面的编写实际上是非常复杂的,虽然它只是一个ListView,但要想让这个ListView滑得动,是的,在一些配置低的手 ...