如何从Mapbox获取高程剖面数据? [英] How to get elevation profile data from Mapbox?

查看:843
本文介绍了如何从Mapbox获取高程剖面数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,如何从 MapBox 服务获取指定路线的海拔剖面.

my question is, how to get an elevation profile of the specified route from the MapBox service.

在输入中,我们将路径/路线作为坐标数组(纬度,经度).结果,我们希望获得坐标对对的数组-高程.

On the input we have path / route as the array of coordinates (latitute, longitute). As the result we would like to get the array of the pairs coordinate - elevation.

如果高程数据的分辨率高于所提供的路线坐标,则结果还应包含原始坐标之间的高程数据.路线上的新点将根据高程数据分辨率生成.如果高程数据的分辨率较低,则应从已知数据中为查询点内插高程值.我们希望获得尽可能精确的结果.

In case the resolution of elevation data is higher than the route coordinates provided, the result should contain also the elevation data between the original coordinates. The new points on the route would be generated according to the elevation data resolution. In case the resolution of elevation data is lower, it should interpolate the elevation values from the known data for the queried points. We would like to get results as precise as possible.

作为我们解决方案的数据源,我们想使用 MapBox 服务.但是,针对此特定问题,我们没有找到任何记录在案的 MapBox API .我们仅找到了对某些,不再受支持.

As the datasource for our solution we would like to use the MapBox service. However we did not find any documented MapBox API for this specific problem. We only found references to some Surface API, that is no longer supported.

据我们了解,Mapbox现在以 Terrain- RGB 地图图块. 我们确定了以下步骤可以使用 MapBox

As we understand Mapbox now stores elevation data in the format of Terrain-RGB map tiles. We identified the following steps to be able to solve our problem using MapBox:

  1. 将路线坐标解码为最小的地图图块.
  2. 使用 MapBox API 查询地图图块.
  3. 对于路线的每个坐标,将其映射到特定的图像像素.
  4. 将像素的RGB颜色值转换为以米为单位的高程.
  1. Decode the route coordinates to the minimal set of map tiles.
  2. Query the map tiles using MapBox API.
  3. For each coordinate of the route, map it to the specific image pixel.
  4. Translate the RGB color value of the pixel to the elevation in meters.

此算法正确吗?我认为,针对特定路线生成高程剖面图是一个常见问题,是否有任何工具可以为我们的问题提供现成的解决方案,也许有一些SDK?我们错过了什么吗?非常感谢.

Is this algorithm correct? I think, that generating elevation profile for specific route is a common problem is there any tool that provides solution for our problem out of the box, maybe some SDK? Are we missing something? Thanks a lot.

推荐答案

简短回答

对于您要实现的目标,我建议您使用Terrain-RGB栅格图块集.相反,您应该使用 Tilequery API 来检索沿路线点的高程来自 Mapbox Terrain v2 矢量图块.

Short Answer

For the goal you have in mind, I would advise not using the Terrain-RGB raster tileset. Rather, you should use the Tilequery API to retrieve the elevation for the points along your route from the Mapbox Terrain v2 vector tileset.

有两种可能的来源和方法可用于从Mapbox检索高程数据,而选择实际上取决于您的需求.链接到以下问题的故障排除文档中会更详细地概述这两种方法: https: //docs.mapbox.com/help/troubleshooting/access-elevation-data/

There are two possible sources and methods that can be used to retrieve elevation data from Mapbox, and the choice really depends on your needs. Both approaches are outlined in greater detail in troubleshooting documentation you've linked to: https://docs.mapbox.com/help/troubleshooting/access-elevation-data/

以下是每种方法的 tl; dr :

这是您在原始问题中概述的过程.如果您想做一些事情,例如准确地设置山体阴影的样式或为视频游戏生成3D网格,则此方法很好.请注意,这种方法不太适合查找特定纬度/经度坐标对的高程.

This is the process you've outlined in your original question. This approach is good if you'd like to do things like styling hillshades accurately or generating a 3D mesh for a video game. Note that this method of not well suited for finding the elevation for specific lat/lon coordinate pairs.

此过程要求您请求路线上每个点的高程.您可以通过向 Mapbox Tilequery API 发出请求来实现.关于需要在路线坐标之间进行插值的观点,可以使用 Turf.js库分解"您的线几何成一组坐标对,然后一次传递给Tilequery API.最重要的是,您可以通过解析来从图块集中检索正确的海拔数据.您从API请求中收到的响应.

This process requires you to request an elevation for each point along your route. You can do this by making requests to the Mapbox Tilequery API. To your point about needing to interpolate coordinates between your route coordinates, you can use the Turf.js library to "explode" your line geometry into an array of coordinate pairs that you then pass to the Tilequery API one at a time. Most importantly, you retrieve the correct elevation data from the tileset by parsing the response you receive from the API request.

⚠️免责声明:我目前在Mapbox⚠️

⚠️ Disclaimer: I currently work at Mapbox ⚠️

这篇关于如何从Mapbox获取高程剖面数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆