分析---影像分析

1.效果图

2.发布服务
  • 在Arccatalog中共享为影像服务
    在这里插入图片描述
  • 发布成功之后查看
  • 说明发布成功
3.引入模块

查询影像数据esri/tasks/ImageServiceIdentifyTask
参数:esri/tasks/ImageServiceIdentifyParameters esri/tasks/ImageServiceIdentifyResult
esri/tasks/ImageServiceIdentifyResult接收返回的参数

影像测量esri/tasks/ImageServiceMeasureTask
参数:esri/tasks/ImageServiceMeasureParameters

4.步骤
  1. 加载图层(不使用动态,使用影像服务)
  2. 创建影像分析和分析方法的参数对象
  3. 绑定事件,获取高程值并弹出
  4. 其中的掩模规则等可以封装为接口,方便以后使用
    5.代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html>
<head>
<title>影像分析</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="https://js.arcgis.com/3.28/esri/css/esri.css" />
<script src="https://js.arcgis.com/3.28/"></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<style>
.MapClass{
width:100%;
height:700px;
border:1px solid #000;
}
</style>
<script>
require(["esri/map","esri/layers/ArcGISImageServiceLayer","dojo/on",
"dojo/dom","esri/toolbars/draw",
"esri/tasks/ImageServiceIdentifyTask","esri/tasks/ImageServiceIdentifyParameters",
"esri/symbols/SimpleLineSymbol","esri/graphic","esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleFillSymbol",
"esri/layers/MosaicRule",
"dojo/domReady!"],function(Map,ArcGISImageServiceLayer,on,dom,Draw,ImageServiceIdentifyTask,
ImageServiceIdentifyParameters,SimpleLineSymbol,
Graphic,SimpleMarkerSymbol,SimpleFillSymbol,MosaicRule){
var map=new Map("mapDiv")

//注意这里是影像服务
var layer=new ArcGISImageServiceLayer("http://localhost:6080/arcgis/rest/services/demo/ImageService_qingdao/ImageServer")
map.addLayer(layer);
//用于绘制点
var toolbar =new Draw(map);

//创建影像分析对象
var task=new ImageServiceIdentifyTask("http://localhost:6080/arcgis/rest/services/demo/ImageService_qingdao/ImageServer");
//创建影像分析参数对象
var params=new ImageServiceIdentifyParameters();
var lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new dojo.Color([255, 0, 0]), 3);
var marker= new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE,10, lineSymbol, new dojo.Color([255, 0, 0]));
var fill= new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, lineSymbol, new dojo.Color([255, 0, 0]));
//给绘制折线按钮绑定事件
on(dom.byId("drawp"),"click",function(){
toolbar.activate(Draw.POINT, {
showTooltips:true
})
})
//给draw工具的绘制完成事件绑定函数
on(toolbar,"draw-complete", function (result) {
map.graphics.clear();
var geometry=result.geometry;
//给参数对象的几何属性赋值
params.geometry =geometry;
graphic= new Graphic(geometry, marker);
map.graphics.add(graphic);
toolbar.deactivate();

})

on(dom.byId("btn"),"click",function(){
//设置掩膜规则
var mosaicRule=new MosaicRule();
mosaicRule.ascending=false;
mosaicRule.method=MosaicRule.METHOD_CENTER
params.mosaicRule=mosaicRule
params.pixelSizeX=layer.pixelSizeX;
params.pixelSizeY=layer.pixelSizeY;
task.execute(params,function(result){
//弹出改点的高程值
alert(result.value)
})
})

});
</script>
</head>

<body>
<div id="mapDiv" class="MapClass"></div>
<button id="drawp">绘制点</button>
<button id="btn">查询</button>
</body>
</html>