3

我还在 SO 的 GIS 部分发布了这个问题。因为我不确定这是否是一个“纯粹的”python 问题,所以我也在这里再次询问。

我想知道是否有人在不使用 ArcGIS的情况下从栅格获取高程数据方面有经验,而是以 pythonlist或获取信息dict

我将我的 XY 数据作为元组列表获取。

我想遍历列表或将其传递给函数或类方法以获取 xy 对的相应高度。

我对该主题进行了一些研究,gdal API 听起来很有希望。谁能建议我如何处理事情,陷阱,示例代码?其他选择?

谢谢你的努力,拉斯维加斯

4

4 回答 4

2

我建议查看Google Elevation API

使用起来非常简单:

http://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&sensor=true_or_false

{
   "results" : [
      {
         "elevation" : 1608.637939453125,
         "location" : {
            "lat" : 39.73915360,
            "lng" : -104.98470340
         },
         "resolution" : 4.771975994110107
      }
   ],
   "status" : "OK"
}

请注意,免费版本每天限制为 2500 个请求。

于 2012-07-16T13:52:14.210 回答
1

我们使用此代码获取给定纬度/经度的海拔(注意:我们只要求打印海拔,以及四舍五入的纬度和经度值)。

import urllib.request
import json
lati = input("Enter the latitude:")
lngi = input("Enter the longitude:")

# url_params completes the base url with the given latitude and longitude values
ELEVATION_BASE_URL = 'http://maps.googleapis.com/maps/api/elevation/json?'
URL_PARAMS = "locations=%s,%s&sensor=%s" % (lati, lngi, "false")
url=ELEVATION_BASE_URL + URL_PARAMS
with urllib.request.urlopen(url) as f:
response = json.loads(f.read().decode())    
status = response["status"]
result = response["results"][0]
print(float(result["elevation"]))
print(float(result["location"]["lat"]))
print(float(result["location"]["lng"]))
于 2013-10-10T18:44:56.087 回答
0

看看高度计是 Google Elevation API 的包装器

于 2013-03-28T08:02:00.837 回答
-1

这是我构建的另一个不错的 API:https ://algorithmia.com/algorithms/Gaploid/Elevation

import Algorithmia

input = {
    "lat": "50.2111",
    "lon": "18.1233"
}
client = Algorithmia.client('YOUR_API_KEY')
algo = client.algo('Gaploid/Elevation/0.3.0')
print algo.pipe(input)
于 2016-07-30T12:32:43.083 回答