當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


JavaScript ArcGIS Ground.queryElevation用法及代碼示例

基本信息

以下是所在類或對象的基本信息。

AMD: require(["esri/Ground"], (Ground) => { /* code goes here */ });

ESM: import Ground from "@arcgis/core/Ground";

類: esri/Ground

繼承: Ground > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

Ground.queryElevation函數(或屬性)的定義如下:

queryElevation (geometry, options) {Promise<ElevationQueryResult>}


查詢給定幾何的高程值的地麵層服務。

返回的結果包含幾何的副本,其中 z-values 從具有可用數據的第一個圖層的高程數據中采樣。可以使用demResolution 選項設置查詢高程的分辨率。在許多情況下,auto demResolution 可用於獲取高質量的高程樣本,而無需知道服務中數據的確切位置。這對於組合來自多個來源的高程數據的服務(例如世界高程服務)特別有用。如果需要更多控製或更高質量的樣本,請使用finest-contiguous 或固定的{number} 分辨率。

參數:

規格:
類型說明

要采樣的幾何圖形。

options Object
可選的

其他查詢選項。

規格:
demResolution

Number|String

可選的
默認值:汽車

控製水平分辨率(像元大小),以米為單位進行高程數據采樣(默認為 auto )。有關不同設置的更多詳細信息,請參見下表。

分辨率 說明
auto 自動為輸入幾何的每個坐標選擇適當的分辨率。當前的實現將嘗試使用最好的可用分辨率,因為所需的磁貼請求總數不超過某個最大數量(當前為 20)。請注意,這可能會導致從不同分辨率采樣值。
finest-contiguous 從整個幾何圖形的最佳可用分辨率(像元大小)中采樣高程。
{number} 從最接近指定分辨率的分辨率采樣高程(以米為單位)。
returnSampleInfo

Boolean

可選的
默認值:錯誤的

指示是否返回每個采樣坐標的附加采樣信息。

noDataValue

Number

可選的
默認值: 0

沒有可用數據時出現在結果幾何圖形中的值。

signal

AbortSignal

可選的

AbortSignal 用於中止請求。如果取消,promise 將被拒絕,並出現名為 AbortError 的錯誤。另見AbortController

返回:

類型 說明
Promise<ElevationQueryResult> 解析為具有采樣幾何、分辨率信息且無數據值的對象。

例子:

require(["esri/Map", "esri/geometry/Multipoint"], function(Map, Multipoint) {
  const map = new Map({
    ground: "world-elevation"
  });

  // Various points across a ridge of the mount everest
  const points = [
     [ 86.9252, 27.9883 ],
     [ 86.9265, 27.9894 ],
     [ 86.9292, 27.9923 ],
     [ 86.9324, 27.9960 ],
     [ 86.9359, 27.9992 ]
   ];

  map.ground.queryElevation(new Multipoint({ points }), { returnSampleInfo: true })

    // Successfully sampled all points
    .then(function(result) {
      // Print result of each sampled point to the console
      result.geometry.points.forEach(function(point, index) {
        const elevation = Math.round(point[2]);
        const resolution = result.sampleInfo[index].demResolution;

        const coordinateText = "(" + point[0] + ", " + point[1] + ")";
        const resolutionText = Math.round(resolution) + " meter resolution";

        console.log("Sampled " + coordinateText + ": " + elevation + " at " + resolutionText);
      });
    })

    // Failed to sample (e.g. service unavailable)
    .catch(function(error) {
      console.error("Failed to query elevation:", error);
    });
});

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 Ground.queryElevation。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。