Difference between revisions of "区域降水实况栅格图API"
Liuzhonghua (talk | contribs) |
Liuzhonghua (talk | contribs) (Tag: Visual edit) |
||
Line 13: | Line 13: | ||
== '''2.API调用方式:''' == | == '''2.API调用方式:''' == | ||
− | <blockquote>2.1 | + | <blockquote>2.1 API接口:<nowiki>http://api.caiyunapp.com/v1/radar/cndata?token=$YOUR_TOKEN</nowiki></blockquote><blockquote>2.2 调用API 获取十帧图的url:降水强度图(共10张)、降水类型图(共10张)、可用区域图(共10张)</blockquote><blockquote>2.3 降水强度图示例:<nowiki>http://cdn.caiyunapp.com/weather/radar/cnmap_precp_201810250540_xxxxxxxxxx.png4</nowiki>. </blockquote><blockquote>2.4 降水类型图示例:<nowiki>http://cdn.caiyunapp.com/weather/radar/cnmap_precptype_201810250540_xxxxxxxxxx.png5</nowiki>. </blockquote><blockquote>2.5 可用区域图示例:<nowiki>http://cdn.caiyunapp.com/weather/radar/cnweight_raw_201810250540_xxxxxxxxxx.png</nowiki></blockquote> |
== '''3.API返回示例:''' == | == '''3.API返回示例:''' == | ||
Line 60: | Line 60: | ||
== '''4.Python参考代码:''' == | == '''4.Python参考代码:''' == | ||
<blockquote>##根据用户经纬度,获取彩云降水''(雪)''强度</blockquote><blockquote>''##lat_interval, lng_interval = 0.009, 0.0105''</blockquote><blockquote>from scipy.misc import imread</blockquote><blockquote>VALID = 255</blockquote><blockquote>NORM = 255</blockquote><blockquote>lats = [3.9079, 57.9079]</blockquote><blockquote>lngs = [71.9282, 150.6026]</blockquote><blockquote>lat_size, lng_size = 6000, 7500</blockquote><blockquote></blockquote><blockquote>def latlng2xy(lat, lng):</blockquote><blockquote>y = int((lng - lngs[0]) / (lngs[1] - lngs[0]) * lng_size)</blockquote><blockquote>x = int((lats[1] - lat) / (lats[1] - lats[0]) * lat_size)</blockquote><blockquote>return x, y</blockquote><blockquote></blockquote><blockquote>data = imread('cnmap_precp_201810250540_7bdef9f9ac.png')</blockquote><blockquote>weight = imread('cnweight_raw_201810250540_7bdef9f9ac.png')</blockquote><blockquote>lat_size, lng_size = data.shape ##(6000, 7500)</blockquote><blockquote>lat, lng = 40.35, 116.31 ##查询用户位置降水情况</blockquote><blockquote>x, y = latlng2xy(lat, lng)</blockquote><blockquote>if weight[x, y] == VALID:</blockquote><blockquote></blockquote><blockquote>result = float(data[x,y]) / NORM</blockquote> | <blockquote>##根据用户经纬度,获取彩云降水''(雪)''强度</blockquote><blockquote>''##lat_interval, lng_interval = 0.009, 0.0105''</blockquote><blockquote>from scipy.misc import imread</blockquote><blockquote>VALID = 255</blockquote><blockquote>NORM = 255</blockquote><blockquote>lats = [3.9079, 57.9079]</blockquote><blockquote>lngs = [71.9282, 150.6026]</blockquote><blockquote>lat_size, lng_size = 6000, 7500</blockquote><blockquote></blockquote><blockquote>def latlng2xy(lat, lng):</blockquote><blockquote>y = int((lng - lngs[0]) / (lngs[1] - lngs[0]) * lng_size)</blockquote><blockquote>x = int((lats[1] - lat) / (lats[1] - lats[0]) * lat_size)</blockquote><blockquote>return x, y</blockquote><blockquote></blockquote><blockquote>data = imread('cnmap_precp_201810250540_7bdef9f9ac.png')</blockquote><blockquote>weight = imread('cnweight_raw_201810250540_7bdef9f9ac.png')</blockquote><blockquote>lat_size, lng_size = data.shape ##(6000, 7500)</blockquote><blockquote>lat, lng = 40.35, 116.31 ##查询用户位置降水情况</blockquote><blockquote>x, y = latlng2xy(lat, lng)</blockquote><blockquote>if weight[x, y] == VALID:</blockquote><blockquote></blockquote><blockquote>result = float(data[x,y]) / NORM</blockquote> | ||
− | |||
[[Category:API 产品]] | [[Category:API 产品]] |
Revision as of 10:31, 14 December 2018
开发者token需要额外开通权限,请联系商务:api@caiyunapp.com
1.API概述 :
- 中国区域降水实况栅格图 API 提供三种文件:降水强度图、可用区域mask图、雨雪类型mask图;
- 文件名为格林威治时间,提供最近十帧(45分钟历史+当前最新),每5分钟更新1次(每小时12次,从00H:00M开始);
- 等经纬度投影,栅格分辨率 (6000 * 7500) , 纬经度分辨率近似为(0.009, 0.0105),(经度分辨率0.0105非准确值);
- 数据第1维 (3.9079N ~ 57.9079N)纬度,第2维 (71.9282E ~ 150.6026E)经度;
- 栅格数据索引和经纬度之间的转换详见下面示例代码;
- 提供的数据如下:
1.降水强度图,数据uint8存储,除以255为彩云降水强度(等于0~1.0之间); 2.降水类型图,数据uint8存储,255代表此像素为雪(固态),100代表此像素为雨(液态),0代表不可用; 3.可用区域图,数据uint8存储,255代表可用(不缺测),0代表不可用。
2.API调用方式:
2.1 API接口:http://api.caiyunapp.com/v1/radar/cndata?token=$YOUR_TOKEN
2.2 调用API 获取十帧图的url:降水强度图(共10张)、降水类型图(共10张)、可用区域图(共10张)
2.3 降水强度图示例:http://cdn.caiyunapp.com/weather/radar/cnmap_precp_201810250540_xxxxxxxxxx.png4.
2.4 降水类型图示例:http://cdn.caiyunapp.com/weather/radar/cnmap_precptype_201810250540_xxxxxxxxxx.png5.
2.5 可用区域图示例:http://cdn.caiyunapp.com/weather/radar/cnweight_raw_201810250540_xxxxxxxxxx.png
3.API返回示例:
URL: http://api.caiyunapp.com/v1/radar/cndata?token=$YOUR_TOKEN
返回示例如下:
{
status*: "ok",
cndata*: [
{
## 降水强度图(UTC+0 格林威治时间)
data_url*: "cdn.caiyunapp.com/weather/radar/ cnmap_precp_201810250540_xxxxxxxxxx.png",
## 降水类型图(UTC+0 格林威治时间)
data_type_url*: "cdn.caiyunapp.com/weather/radar/ cnmap_precptype_201810250540_xxxxxxxxxx.png",
## 可用区域图(UTC+0 格林威治时间)
weight_url*: "cdn.caiyunapp.com/weather/radar/cnweight_raw_201810250540_xxxxxxxxxx.png",
datatime*: 1540446000, # 降雨图的时间戳(UTC+0 格林威治时间)
lat*: [3.9079,57.9079], # 纬度范围
lng*: [71.9282,150.6026], # 经度范围
unit*: "grey scale" # 灰度单位,降雨图数据除以255为彩云降水强度;
# 可用范围数据中,255代表可用,0代表不可用
},
...
]
}
4.Python参考代码:
##根据用户经纬度,获取彩云降水(雪)强度
##lat_interval, lng_interval = 0.009, 0.0105
from scipy.misc import imread
VALID = 255
NORM = 255
lats = [3.9079, 57.9079]
lngs = [71.9282, 150.6026]
lat_size, lng_size = 6000, 7500
def latlng2xy(lat, lng):
y = int((lng - lngs[0]) / (lngs[1] - lngs[0]) * lng_size)
x = int((lats[1] - lat) / (lats[1] - lats[0]) * lat_size)
return x, y
data = imread('cnmap_precp_201810250540_7bdef9f9ac.png')
weight = imread('cnweight_raw_201810250540_7bdef9f9ac.png')
lat_size, lng_size = data.shape ##(6000, 7500)
lat, lng = 40.35, 116.31 ##查询用户位置降水情况
x, y = latlng2xy(lat, lng)
if weight[x, y] == VALID:
result = float(data[x,y]) / NORM