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. 开发BI系统时的需求分析研究

    我们知道MIS,知道ERP,知道GIS等等,这些系统在管理限制上有很多的冲突,管理和被管理,开放和限制等等,然而BI在开始就不是这样的.BI要求的就是易用还要易于扩展,首先是报表,这个是你无条件的需要 ...

  2. mybatis配置文件(其中,注意节点先后顺序)

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC & ...

  3. 哇塞,原来自己写 Google Chrome 浏览器扩展(插件)这么容易!

    1. 首先新建一个记事本,命名为 manifest.json,这是写 Google Chrome 浏览器扩展必须的文件 { "manifest_version": 2, " ...

  4. MyEclipse8.5集成Tomcat7时的启动错误:Exception in thread “main” java.lang.NoClassDefFoundError org/apache/commons/logging/LogFactory

    今天,安装Tomcat7.0.21后,单独用D:\apache-tomcat-7.0.21\bin\startup.bat启动web服务正常.但在MyEclipse8.5中集成配置Tomcat7后,在 ...

  5. iOS- 微信支付 (服务器调起支付 )以及回调不成功的原因 不看后悔

    写的不错,给留个言哈... 一. 支付准备工作 1. 微信相关准备工作 (1) 向微信官方开通支付功能. 这个不是前端的工作. (2) 导入官方下载的微信支付SDK包. 我用的是微信开放平台下载的SD ...

  6. NoSuchMethodError: antlr.collections.AST.getLine()I

    错误完整表述: Filter execution threw an exception] with root cause java.lang.NoSuchMethodError: antlr.coll ...

  7. [ORM] Entity Framework(1) CodeFirst快速入门

    Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R Mapping) 解决方案 对象关系映射(英语:Object Relational Mapping ...

  8. 使用Swift操作NSDate类型基础

    时间类型是我们在处理业务的时候使用非常频繁的一个数据类型.下面我们看一下时间NSDate的基本使用方法. 1.比较大小 我比较擅长.NET,我们知道C#里面DateTime类型可以使用"&g ...

  9. Lucene-Analyzer

    Lucene文本解析器实现 把一段文本信息拆分成多个分词,我们都知道搜索引擎是通过分词检索的,文本解析器的好坏直接决定了搜索的精度和搜索的速度. 1.简单的Demo private static fi ...

  10. BI之SSAS完整实战教程1 -- 开篇, BI简介 & SSAS简介

    文章提纲 商业智能(BI, Business Intelligence)基本概念 SSAS(SQL Server Analysis Services)相关工具(开发.管理和客户端) 总结 一.商业智能 ...