当前位置: 首页 > news >正文

11 - ArcGIS For JavaScript -- 高程分析

这里写自定义目录标题

  • 描述
  • 代码实现
  • 结果

描述

高程分析是地理信息系统(GIS)中的核心功能之一,主要涉及对地表高度数据(数字高程模型, DEM)的处理和分析。
ArcGIS For JavaScript4.32版本的发布,提供了Web端的针对高程分析的功能。

代码实现

<!doctype html>
<html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /><title>地形高程分析</title><link rel="stylesheet" href="https://js.arcgis.com/4.32/esri/themes/light/main.css" /><script src="https://js.arcgis.com/4.32/"></script><style>html,body,#viewDiv {padding: 0;margin: 0;height: 100%;width: 100%;background-color: ghostwhite;}#opacitySliderDiv {background: #607d8bbb;padding: 10px;border-radius: 5px;}#opacitySliderDiv label {margin: 5px 0;text-align: left;display: block;color: #1833c8;}</style><script>require(["esri/Map","esri/views/SceneView","esri/layers/support/RasterFunction","esri/layers/support/rasterFunctionUtils","esri/layers/ImageryTileLayer","esri/widgets/Slider","esri/widgets/Expand"], (Map,SceneView,RasterFunction,rasterFunctionUtils,ImageryTileLayer,Slider,Expand) =>(() => {let customColor = [0, 122, 194];const customAnalysisParams = {elevation: { min: 2000, max: 9000 },slope: { min: 10, max: 90 },aspects: { N: false, NE: false, E: false, SE: true, S: true, SW: true, W: false, NW: false }};function createCustomAnalysis(color = customColor) {// Mask out elevation outside of parameter rangeconst elevationMask = rasterFunctionUtils.mask({includedRanges: [[customAnalysisParams.elevation.min, customAnalysisParams.elevation.max]],noDataValues: [[-9999]],noDataInterpretation: "match-any"});// Compute slope on masked elevationconst slopeFunction = rasterFunctionUtils.slope({slopeType: "degree",zFactor: 1,raster: elevationMask});// Mask out slopes outside of parameter rangeconst slopeMask = rasterFunctionUtils.mask({includedRanges: [[customAnalysisParams.slope.min, customAnalysisParams.slope.max]],noDataValues: [[-9999]],noDataInterpretation: "match-any",raster: slopeFunction});// Map included slopes >= 0 to 1const greaterThanSlope0 = rasterFunctionUtils.greaterThanEqual({raster: slopeMask,raster2: 0});// Compute aspect on masked elevationconst aspectFunction = rasterFunctionUtils.aspect({raster: elevationMask});// Map aspect as 1 (include) or 0 (exclude) according to parametersconst remapAspectFunction = rasterFunctionUtils.remap({rangeMaps: [{ range: [-Infinity, 0], output: 1 }, // Include flats{ range: [360, Infinity], output: 1 }, // Include flats{ range: [337.5, 360], output: +customAnalysisParams.aspects.N },{ range: [0, 22.5], output: +customAnalysisParams.aspects.N },{ range: [22.5, 67.5], output: +customAnalysisParams.aspects.NE },{ range: [67.5, 112.5], output: +customAnalysisParams.aspects.E },{ range: [112.5, 157.5], output: +customAnalysisParams.aspects.SE },{ range: [157.5, 202.5], output: +customAnalysisParams.aspects.S },{ range: [202.5, 247.5], output: +customAnalysisParams.aspects.SW },{ range: [247.5, 292.5], output: +customAnalysisParams.aspects.W },{ range: [292.5, 337.5], output: +customAnalysisParams.aspects.NW }],raster: aspectFunction});// Combine slope and aspect rastersconst combineAspectSlope = rasterFunctionUtils.booleanAnd({raster: greaterThanSlope0,raster2: remapAspectFunction});const colorMapFinal = rasterFunctionUtils.colormap({colormap: [[1, ...color]],raster: combineAspectSlope});return colorMapFinal;}const analysisLayer = new ImageryTileLayer({url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer",title: "Custom Analysis",rasterFunction: createCustomAnalysis(customColor),opacity: 0.8});let scene = new Map({basemap: 'hybrid',ground: 'world-elevation'});scene.add(analysisLayer);let view = new SceneView({container: 'viewDiv',map: scene,camera: {heading: 11.318022273157128,fov: 55,tilt: 64.97027885113135,position: {longitude: 102.01508901208386,latitude: 28.892260981774943,z: 19722.28977170773}}});view.when(function () {console.log(view.map);analysisLayer.rasterFunction = colorMapElevation;const slider = new Slider({container: "opacitySlider",min: 0,max: 100,values: [20],steps: 1,snapOnClickEnabled: false,visibleElements: {labels: true,rangeLabels: true}});slider.on('thumb-drag', (evt) => {if (evt.state === 'stop') {analysisLayer.opacity = 1 - evt.value / 100;}});})const colorMapElevation = rasterFunctionUtils.colormap({colorRampName: "elevation1"});view.ui.add('opacitySliderDiv', 'top-right')})());</script>
</head>
<body><div id="viewDiv"><div id="opacitySliderDiv"><label htmlFor="bloomContrast">高程分析 | 透明度:</label><div id="opacitySlider" style="width: 300px;height: 20px;margin: 10px 0px"></div></div></div></div>
</body></html>

结果

在这里插入图片描述

相关文章:

  • day38 6月5号
  • golang 如何定义一种能够与自身类型值进行比较的Interface
  • ignore文件不生效的问题
  • JVM垃圾回收器-ZGC
  • 【赵渝强老师】Docker的图形化管理工具
  • 行内样式:深入解析与应用指南
  • SpringCloud——OpenFeign
  • 大模型的开发应用(七):大模型的分布式训练
  • AtCoder-abc408_b 解析
  • snprintf函数用法及注意事项详解
  • 【鸿蒙在 ETS (Extendable TypeScript) 中创建多级目录或文件,可以使用鸿蒙的文件系统 API】
  • 力扣刷题Day 71:搜索旋转排序数组(33)
  • Win10、Win11系统,使用谷歌浏览器文件流下载,C盘剩余容量小于4GB时,下载失败问题
  • 我的创作纪念日——聊聊我想成为一个创作者的动机
  • 25.6.5学习总结
  • 风机下引线断点检测算法实现
  • 系统思考持续训练
  • 【Redis】笔记|第10节|京东HotKey实现多级缓存架构
  • 简化复杂系统的优雅之道:深入解析 Java 外观模式
  • AI大模型在测试领域应用案例拆解:AI赋能的软件测试效能跃迁的四大核心引擎(顺丰科技)
  • 网站建设免费空间注册导航/抖音搜索排名优化
  • 网站的申请/百度关键词seo优化
  • 付费的网站推广该怎么做/济南seo公司
  • 电子商务网站建设需要什么/广告公司推广平台
  • 网站页脚信息/模板下载网站
  • 品牌推广怎么做/智推教育seo课程