How to load a raster dataset to the raster field in a feature class
Loading a raster dataset to the raster field in a feature class
- Get a workspace for editing.
- Find the raster field index.
- Create a raster value object with an input raster dataset.
- Set the raster value to the raster field.
- Stop editing and save.
[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的更多相关文章
- ArcEngine和GDAL读写栅格数据机制对比(二)—— IPixelBlock读写栅格
以下是设定一个矩形框,用IPixelBlock将256*256瓦片tile拼接成一个整块影像的代码,row1, col1, row2, col2是一个矩形框行列号范围.level是瓦片的金字塔等级.这 ...
- esriFeatureType与esriGeometryType的区别与联系
esriFeatureType通常用来表示数据的存储结构,即物理层: esriGeometryType通常用来表示数据的几何形状,即表现层. esriGeometryType枚举类型详解 常量 值 对 ...
- Regression:Generalized Linear Models
作者:桂. 时间:2017-05-22 15:28:43 链接:http://www.cnblogs.com/xingshansi/p/6890048.html 前言 本文主要是线性回归模型,包括: ...
- 机器学习算法整理(一)线性回归与梯度下降 python实现
回归算法 以下均为自己看视频做的笔记,自用,侵删! 一.线性回归 θ是bias(偏置项) 线性回归算法代码实现 # coding: utf-8 get_ipython().run_line_mag ...
- Generalized Linear Models
作者:桂. 时间:2017-05-22 15:28:43 链接:http://www.cnblogs.com/xingshansi/p/6890048.html 前言 主要记录python工具包:s ...
- ArcEngine和GDAL读写栅格数据机制对比(一)
最近应用AE开发插值和栅格转等值线的程序,涉及到栅格读写的有关内容.联想到ArcGIS利用了GDAL的某些东西,从AE的OMD中也发现RasterDataset和RasterBand这些命名和GDAL ...
- 吴裕雄--天生自然 python数据分析:健康指标聚集分析(健康分析)
# This Python 3 environment comes with many helpful analytics libraries installed # It is defined by ...
- 深度学习原理与框架-神经网络-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,表示从上到下进行串接 ...
- Client Dataset Basics
文章出处: http://www.informit.com/articles/article.aspx?p=24094 In the preceding two chapters, I discus ...
随机推荐
- 关于app.config不能即时保存读取的解决方案
public void saveValue(string Name, string Value) { ConfigurationManager.AppSettings.Set(Name, Value) ...
- 同时使用Twitter nlp 和stanford parser的解决方法
因为Twitter nlp中使用了较老版本的stanford parser,导致不能同时使用 解决方法是使用未集成其它jar包的Twitter nlp,关于这点Stanford FAQ中也有说明(在F ...
- WPA字典锦集
1.xiemimendictionary 字典下载(第二季),500W整理过后还有282W条不重复的密码 字典下载,600W整理过后还有400W条不重复的密码 历次泄+常用弱口令字典集合[无中文去重复 ...
- C#基础总结之六 DataTable (临时表/数据源) 和Datatable 名片练习
#region DataTable (临时表/数据源) 存储数据 DataTable dataTable = new DataTable(); dataTable.Columns.Add(" ...
- MyBatis知多少(9)不同类型的数据库
并非所有的数据库都如此复杂,需要使用昂贵的数据库管理系统以及企业级的硬件.一些数 据库其实非常小,足以运行在一台老式的PC机上.所有的数据库都是不一样的.它们有各自不 同的需求和不同的挑战.iBATI ...
- 批量修改Project视图中Prefab的名字
简要代码如下: using UnityEditor; using UnityEngine; using System.IO; using System.Collections; using Syste ...
- 【转载】两个排序数组的中位数 / 第K大元素(Median of Two Sorted Arrays)
转自 http://blog.csdn.net/zxzxy1988/article/details/8587244 给定两个已经排序好的数组(可能为空),找到两者所有元素中第k大的元素.另外一种更加具 ...
- spring boot 拦截器
@SpringBootApplicationpublic class Application extends WebMvcConfigurerAdapter { public static void ...
- 如何准备阿里社招面试,顺谈 Java 程序员学习中各阶段的建议
引言 其实本来真的没打算写这篇文章,主要是LZ得记忆力不是很好,不像一些记忆力强的人,面试完以后,几乎能把自己和面试官的对话都给记下来.LZ自己当初面试完以后,除了记住一些聊过的知识点以外,具体的内容 ...
- Tiff – 值得你体验一下的可视化的字体对比工具
Tiff 是一款字体对比工具,可视化对比两种字体之间的差异.这是一个工具来帮助比较两种字体,同时学习排版.在这一点上,谷歌 Web 字体作为 Tiff 外部字体文件的唯一来源.由于应用程序使用的一些功 ...