ArcGIS API For Flex对ImageServer发布的服务进行渲染及RasterFunction支持函数(学习笔记)

原文地址:http://blog.csdn.net/lxping1012/article/details/7477811

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 Aspect raster function takes no arguments. Hence, specifying only the rasterFunction property suffices in this case.

{
  "rasterFunction" : "Aspect"
}

"rasterFunction" : "Colormap"

The arguments for the Colormap function are as shown below:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "ColormapName" : "",
    "Colormap" : [
      [, , , ], //[int, int, int, int]
      [, , , ]
    ]
  },
  "variableName" : "Raster"
}

Example 1:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "ColormapName" : "Random"
  },
  "variableName" : "Raster"
}

Example 2:

{
  "rasterFunction" : "Colormap",
  "rasterFunctionArguments" : {
    "Colormap" : [
      [0, 1, 2, 3],
      [2, 45, 52, 13]
    ]
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Hillshade"

The arguments for the Hillshade function are as shown below:

{
  "rasterFunction" : "Hillshade",
  "rasterFunctionArguments" : {
    "Azimuth" : , //double (e.g. 215.0)
    "Altitude" : , //double (e.g. 75.0)
    "ZFactor" :  //double (e.g. 0.3)
  },
  "variableName" : "DEM"
}

Example:

{
  "rasterFunction" : "Hillshade",
  "rasterFunctionArguments" : {
    "Azimuth" : 215.0,
    "Altitude" : 75.0,
    "ZFactor" : 0.3
  },
  "variableName" : "DEM"
}

"rasterFunction" : "NDVI"

The arguments for the NDVI function are as shown below:

{
  "rasterFunction" : "NDVI",
  "rasterFunctionArguments" : {
    "VisibleBandID" : , //int (zero-based band id, e.g. 2)
    "InfraredBandID" :  //int (zero-based band id, e.g. 1)
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "NDVI",
  "rasterFunctionArguments" : {
    "VisibleBandID" : 2,
    "InfraredBandID" : 1
  },
  "variableName" : "Raster"
}

"rasterFunction" : "ShadedRelief"

The arguments for the ShadedRelief function are as shown below:

{
  "rasterFunction" : "ShadedRelief",
  "rasterFunctionArguments" : {
    "Azimuth" : , //double (e.g. 215.0)
    "Altitude" : , //double (e.g. 75.0)
    "ZFactor" : , //double (e.g. 0.3)
    "Colormap" : [
      [, , , ], //[int, int, int, int]
      [, , , ]
    ]
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "ShadedRelief",
  "rasterFunctionArguments" : {
    "Azimuth" : 215.0,
    "Altitude" : 75.0,
    "ZFactor" : 0.3,
    "Colormap" : [
      [0, 1, 2, 3],
      [2, 45, 52, 13]
    ]
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Slope"

The arguments for the Slope function are as shown below:

{
  "rasterFunction" : "Slope",
  "rasterFunctionArguments" : {
    "ZFactor" :  //double (e.g. 0.3)
  },
  "variableName" : "DEM"
}

Example:

{
  "rasterFunction" : "Slope",
  "rasterFunctionArguments" : {
    "ZFactor" : 0.3
  },
  "variableName" : "DEM"
}

"rasterFunction" : "Statistics"

The arguments for the Statistics function are as shown below:

{
  "rasterFunction" : "Statistics",
  "rasterFunctionArguments" : {
    "Type" : "",
    "KernelColumns" : , //int (e.g. 3)
    "KernelRows" :  //int (e.g. 3)
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Statistics",
  "rasterFunctionArguments" : {
    "Type" : "Mean",
    "KernelColumns" : 3,
    "KernelRows" : 3
  },
  "variableName" : "Raster"
}

"rasterFunction" : "Stretch"

The arguments for the Stretch function are as shown below:

{
  "rasterFunction" : "Stretch",
  "rasterFunctionArguments" : {
    "StretchType" : , //int (0 = None, 3 = StandardDeviation, 4 = Histogram Equalization, 5 = MinMax)
    "NumberOfStandardDeviations" : , //int (e.g. 2)
    "Statistics" : [
      [, , , ], //[double, double, double, double]
      [, , , ]
    ],
    "Gamma" : [, ] //array of doubles
  },
  "variableName" : "Raster"
}

Example:

{
  "rasterFunction" : "Stretch",
  "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, 2, 3.95]
  },
  "variableName" : "Raster"
}
我们 可以从上面的函数中利用ShadedRelief函数完成渲染,有关代码如下

[java]  view plain  copy
 print ?
  1. rasterArgs = {};  
  2. rasterArgs["Colormap"] = ColorsGradient([new Color(150,255,255),new Color(255,255,150),new Color(255,150,150)]);                       //ColorsGradient上一篇文章所写的函数  
  3. rasterArgs["Azimuth"] =215;  
  4. rasterArgs["Altitude"] =75;  
  5. rasterFunction.arguments=rasterArgs;  
  6. rasterFunction.functionName = "ShadedRelief";  
  7. imageLayer.renderingRule = rasterFunction;    //imageLayer为ArcGISImageServiceLayer  

这样就可以进行渲染了,但是值得我们注意的是,服务中栅格数据到底是离散型还是连续型的,上面提到的函数都针对不同的数据类型。

你可能感兴趣的:(转载)