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 ...
随机推荐
- python 字符串查找
python 字符串查找有4个方法,1 find,2 index方法,3 rfind方法,4 rindex方法. 1 find()方法: )##从下标1开始,查找在字符串里第一个出现的子串:返回结果3 ...
- [原]Android打包之跨平台打包
Android自动打包流程详细图: 在前面一些博客我们知道了如何通过命令行打包,如何通过Eclipse打包,如何通过编写shell脚本来进行打包,但是这些都不能很好的跨平台进行打包. 因Python本 ...
- C# 通过WebService方式 IIS发布网站 上传文件到服务器
应用场景:要将本地的文件 上传到服务器的虚拟机上 网络环境:公司局域网(如下图中第二种) 开发环境:VS2010 服务器环境:WinServer2008 虚拟机环境:WinServer2008 ...
- NGUI 基础知识
UIRoot 管理 scalePixelPerfect : 像素匹配,图片不会被缩放,除非屏幕高度小于 Minimum Height 或者大于 maximum Height,如果那样的话,就使用 F ...
- 数据可视化(4)--jqplot
本来打算继续研究Google Charts,但上头下了指示让看jqplot,无奈,只好先将Google Charts放一放,不过真心觉得Google Charts不错,现在先开始jqplot. jqP ...
- Linux磁盘操作命令
查看本地磁盘使用情况:df或者df -l单位为k 容量便于查看,以1024单位换算为M或者G等:df -h或者df -lh 以1000为单位换算:df -H 显示文件系统类型:df -T 显示指定文件 ...
- PEP8 Python 编码规范
一 代码编排1 缩进.4个空格的缩进(编辑器都可以完成此功能),不使用Tap,更不能混合使用Tap和空格.2 每行最大长度79,换行可以使用反斜杠,最好使用圆括号.换行点要在操作符的后边敲回车.3 类 ...
- iOS10新特性之CallKit开发详解:锁屏接听和来电识别
国庆节过完了,回家好好休息一天,今天好好分享一下CallKit开发.最近发现好多吃瓜问CallKit的VoIP开发适配,对iOS10的新特性开发和适配也在上个月完成,接下来就分享一下VoIP应用如何使 ...
- IOS中对象的归档
ios提供了两个类 NSKeyedArichiver NSKeyedUnarchiver对自定义对象进行归档 和解档操作 归档常见方法 - (void)encodeObject:(id)objv fo ...
- ASP.NET和MSSQL高性能分页
首先是存储过程,只取出我需要的那段数据,如果页数超过数据总数,自动返回最后一页的纪录: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO -- ======= ...