arcgis 数据和服务中的z值,以及地下三维展示(附代码)
生活随笔
收集整理的這篇文章主要介紹了
arcgis 数据和服务中的z值,以及地下三维展示(附代码)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近在進行地圖符號的三維配置,在嘗試三維符號時,發現無論如何都無法出現地下的效果,很郁悶,終于在好閨蜜的幫助下了解到了關于數據和服務的z值
一、什么是z值
z 值通常表示可用于以三維形式顯示要素的高程或高度。要素的各折點可將 z 值與 x,y 位置信息一同存儲。雖然 ArcMap 及其編輯環境是二維的,但仍可以輸入、編輯和維護 z 值。
在 ArcMap 中執行編輯操作時,z 值的分配由編輯工具或命令所執行的常規功能決定:是創建新要素還是編輯現有要素。所創建的、用于生成新要素的大多數操作都會為所有折點分配相同的默認 z 值。修改現有要素時,將內插新的 z 值,并將更新后的值分配給已編輯的折點。但是,某些編輯操作只會維護現有 z 值。
二、新建帶有z值的要素類或shp并賦予z值
1、新建帶有z值的要素類或shp
在catalog中新建shp或要素類,命名選擇類型并勾選“坐標將包含z值”。
2、新建z值字段
在屬性表中添加字段,并賦值(示例中由于點位于地下,所以z賦值負值,若在地上則賦值正值)
3、設置z值等于賦予的z字段值
打開工具箱<<數據管理工具<<要素<<調整3D的z值
這樣,就可以得到包含z值的數據了,三維效果也就可以展示啦
三、展示地下三維
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>三維test</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
100%;
}
#homeDiv {
left: 15px;
top: 130px;
z-index: 35;
position: absolute;
}
</style>
<link rel="stylesheet" href="http://ip/arcgis_api/4.11/esri/themes/light/main.css" />
<script src="http://ip/arcgis_api/4.11/init.js"></script>
<script>
require([
"esri/Map",
"esri/Basemap",
"esri/layers/ElevationLayer",
"esri/layers/BaseElevationLayer",
"esri/views/SceneView",
"esri/layers/FeatureLayer",
"esri/layers/MapImageLayer",
"esri/widgets/Home"
], function (Map, Basemap, ElevationLayer, BaseElevationLayer, SceneView, FeatureLayer, MapImageLayer, Home) {
var xzqh = "http://ip:6080/arcgis/rest/services/test/xzqh_test/MapServer";
var precipiation = "http://ip:6080/arcgis/rest/services/test/precipiation_test/MapServer";
var elevation = "http://ip:6080/arcgis/rest/services/Elevation/NMG_DEM_30m/ImageServer";
var ore = "http://ip:6080/arcgis/rest/services/test/mine/MapServer/0";
var oreIM = "http://ip:6080/arcgis/rest/services/test/mine/MapServer";
var Extent = {
xmax: 1.40336476624E7,
xmin: 1.08169663638E7,
ymax: 7044962.961599998,
ymin: 4495920.4575999975,
spatialReference: {
wkid: 3857
}
};
var baseLayer = new MapImageLayer({
title: "行政區劃",
url: xzqh
});
var basemap = new Basemap({
baseLayers: [baseLayer],
title: "行政區劃",
});
var elevLyr = new ElevationLayer({
url: elevation,
spatialReference: {
wkid: 4326
}
});
var depthRenderer = {
type: "simple",
symbol: {
type: "point-3d",
symbolLayers: [
{
type: "object",
resource: {
primitive: "sphere"
}
}
]
},
visualVariables: [
{
type: "color",
field: "type_num",
//地下符號顏色
stops: [
{
value: "1",
color: "yellow"
},
{
value: "2",
color: "white"
},
{
value: "3",
color: "red"
},
{
value: "4",
color: "blue"
},
{
value: "5",
color: "green"
},
{
value: "6",
color: "black"
}
]
},
{
type: "size",
field: "OreReserve",
axis: "all",
stops: [
{
value: 1000,
size: 2000
},
{
value: 2000,
size: 40000
}
]
}
]
};
var surfaceSym = {
type: "point-3d",
symbolLayers: [
{
type: "icon",
resource: {
primitive: "circle"
}
}
]
};
var SurfaceRenderer = {
type: "simple",
symbol: surfaceSym,
visualVariables: [
{
type: "size",
field: "OreReserve",
axis: "all",
stops: [
{
value: 1000,
size: 15
},
{
value: 2000,
size: 40
}
]
},
{
type: "color",
field: "type_num",
//地下符號顏色
stops: [
{
value: "1",
color: "yellow"
},
{
value: "2",
color: "white"
},
{
value: "3",
color: "red"
},
{
value: "4",
color: "blue"
},
{
value: "5",
color: "green"
},
{
value: "6",
color: "black"
}
]
}
]
};
var KCTemplate = {
title: "{ORETYPE}礦",
content: "{*}"
}
var DepthLayer = new FeatureLayer({
url: ore,
outFields: ["*"],
renderer: depthRenderer,
popupTemplate: KCTemplate,
elevationInfo: {
mode: "relative-to-ground"
}
});
var SurfaceLayer = new FeatureLayer({
url: ore,
outFields: ["*"],
renderer: SurfaceRenderer,
popupTemplate: KCTemplate,
opacity: 0.6,
elevationInfo: {
mode: "on-the-ground"
}
});
var map = new Map({
basemap: basemap,
layers: [
DepthLayer,
SurfaceLayer
],
ground: {
navigationConstraint: {
type: "none"
}
}
});
var view = new SceneView({
container: "viewDiv",
map: map,
viewingMode: "local",
clippingArea: Extent,
extent: Extent
});
var homeBtn = new Home(
{
view: view
},
"homeDiv"
);
});
</script>
</head>
<body>
<div id="viewDiv"></div>
<div id="homeDiv"></div>
</body>
</html>
效果如下:
總結
以上是生活随笔為你收集整理的arcgis 数据和服务中的z值,以及地下三维展示(附代码)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#/WPF程序开机自动启动
- 下一篇: 洛谷 P4011 孤岛营救问题【最短路+