ArcGIS API For Flex对ImageServer发布的服务进行渲染及RasterFu
ArcGIS Server中的 Image Service 能够提供对影像原始数据的动态访问,得到其元数据(metadata): 包括自定义的空间参考,图幅范围,像元大小,像元类型,波段数,以及各波段的基础统计信息(最小值,最大值,平均值之 类);能够根据相关参数生成新的影像,同时在arcgis server 10版本中还添加了针对栅格数据的查询和下载功能。最重要的是不同 于map service(不论是cache或non-cache),能够对影像做一些处理,比如计算NDVI,坡度,坡向,进行Standard Deviation拉 伸、直方图均匀化拉伸,minmax拉伸等基本处理。虽然和专门的影像处理软件完全不能比较,但是能在网络上进行遥感影像处理。 为了能利用ArcGIS Flex API浏览ImageServer服务并对栅格地图进行渲染,我参考了ArcGIS有关服务的帮助和例子http:/ /help.arcgis.com/en/webapi/flex/samples/index.html#/Shaded_relief_raster_function/01nq00000066000000/里面 讲解了ImageServer服务几种栅格渲染的方法,ArcGISImageServiceLayer是通过renderingRule来进行渲染的, 但renderingRule的类型为RasterFunction,看到RasterFunction中的functionName和arguments属性,这让我一头雾水。
后来经过大量的搜查,终于被我从ArcGIS Server REST API的帮助中找到,functionName为RasterFunction的函数名,
arguments为实现该函数的参数,下面是RasterFunction支持的函数:
"rasterFunction" : "Aspect" The? { "rasterFunction" : "Aspect" } "rasterFunction" : "Colormap" The arguments for the? {
"rasterFunction" : "Colormap","rasterFunctionArguments" : {
"ColormapName" : "<Random | NDVI | Elevation | Gray>","Colormap" : [
[<value1>,<red1>,<green1>,<blue1>],//[int,int,int]
[<value2>,<red2>,<green2>,<blue2>]
]
},"variableName" : "Raster"
}
Example 1: Example 2:
"rasterFunction" : "Hillshade"Hillshade?function are as shown below: {
"rasterFunction" : "Hillshade","rasterFunctionArguments" : {
"Azimuth" : <Azimuth>,119)">//double (e.g. 215.0)
"Altitude" : <Altitude>,119)">//double (e.g. 75.0)
"ZFactor" : <ZFactor> //double (e.g. 0.3)
},"variableName" : "DEM"
}
Example: NDVI?function are as shown below: {
"rasterFunction" : "NDVI","rasterFunctionArguments" : {
"VisibleBandID" : <VisibleBandID>,119)">//int (zero-based band id,e.g. 2)
"InfraredBandID" : <InfraredBandID>
"rasterFunction" : "ShadedRelief"
ShadedRelief?function are as shown below: {
"rasterFunction" : "ShadedRelief",119)">//double (e.g. 75.0)
"ZFactor" : <ZFactor>,119)">//double (e.g. 0.3)
"Colormap" : [
[<value1>,"ZFactor" : 0.3,"Colormap" : [
[0,"variableName" : "Raster"
}
"rasterFunction" : "Slope"
Slope?function are as shown below: {
"rasterFunction" : "Slope","rasterFunctionArguments" : {
"ZFactor" : <ZFactor>
"rasterFunction" : "Statistics"
Statistics?function are as shown below: {
"rasterFunction" : "Statistics","rasterFunctionArguments" : {
"Type" : "<Min | Max | Mean | StandardDeviation>","KernelColumns" : <KernelColumns>,119)">//int (e.g. 3)
"KernelRows" : <KernelRows> //int (e.g. 3)
},"rasterFunctionArguments" : {
"Type" : "Mean","KernelColumns" : 3,"KernelRows" : 3
},"variableName" : "Raster"
}
"rasterFunction" : "Stretch"
Stretch?function are as shown below: {
"rasterFunction" : "Stretch","rasterFunctionArguments" : {
"StretchType" : <StretchType>,119)">//int (0 = None,3 = StandardDeviation,4 = Histogram Equalization,5 = MinMax)
"NumberOfStandardDeviations" : <NumberOfStandardDeviations>,119)">//int (e.g. 2)
"Statistics" : [
[<min1>,<max1>,<mean1>,<standardDeviation1>],119)">//[double,double,double]
[<min2>,<max2>,<mean2>,<standardDeviation2>]
],"Gamma" : [<gamma1>,<gamma2>] //array of doubles
},"rasterFunctionArguments" : {
"StretchType" : 3,"NumberOfStandardDeviations" : 2,"Statistics" : [
[0.2,222.46,99.35,1.64],[5.56,100.345,45.4,3.96],[0,352.37,172.284,2]
],"Gamma" : [1.25,3.95]
},"variableName" : "Raster"
}
我们
可以从上面的函数中利用ShadedRelief函数完成渲染,有关代码如下:
rasterArgs = {}; rasterArgs["Colormap"] = ColorsGradient([new Color(150,255,255),new Color(255,150),150,150)]); //ColorsGradient上一篇文章所写的函数 rasterArgs["Azimuth"] =215; rasterArgs["Altitude"] =75; rasterFunction.arguments=rasterArgs; rasterFunction.functionName = "ShadedRelief"; imageLayer.renderingRule = rasterFunction; //imageLayer为ArcGISImageServiceLayer这样就可以进行渲染了,但是值得我们注意的是,服务中栅格数据到底是离散型还是连续型的,上面提到的函数都针对不同的数据类型。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |