Tellus SLATS

Tellus

https://www.tellusxdp.com/ja/

Result

Original data provided by JAXA
Original data provided by JAXA

Code

import os, json, requests, math
import numpy as np
import dateutil.parser
from datetime import datetime
from datetime import timezone
from skimage import io
from io import BytesIO
import matplotlib.pyplot as plt

TOKEN = "Input your token"

def get_tsubame_scene(min_lat, min_lon, max_lat, max_lon):
    url = "https://gisapi.tellusxdp.com/api/v1/tsubame/scene" \
        + "?min_lat={}&min_lon={}&max_lat={}&max_lon={}".format(min_lat, min_lon, max_lat, max_lon)
    headers = {
        "Authorization": "Bearer " + TOKEN
    }
    r = requests.get(url, headers=headers)
    return r.json()

tsubame_scenes = get_tsubame_scene(35.524375, 139.585347, 35.724375, 140.005347)

print(len(tsubame_scenes))
print(tsubame_scenes[0])

ext_scene = tsubame_scenes[0]

# 表示
io.imshow(io.imread(tsubame_scenes[0]["thumbs_url"]))
from PIL import Image

def get_tile_num(lat_deg, lon_deg, zoom):
    # https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Python
    lat_rad = math.radians(lat_deg)
    n = 2.0 ** zoom
    xtile = int((lon_deg + 180.0) / 360.0 * n)
    ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
    return (xtile, ytile)

def get_tsubame_image(scene_id, zoom, xtile, ytile):
    url = " https://gisapi.tellusxdp.com/tsubame/{}/{}/{}/{}.png".format(scene_id, zoom, xtile, ytile)
    headers = {
        "Authorization": "Bearer " + TOKEN
    }
    r = requests.get(url, headers=headers)
    return io.imread(BytesIO(r.content))

def get_slat_series_image(scene_id, zoom, topleft_x, topleft_y, size_x=1, size_y=1):
    """切り出したタイル画像を結合する"""
    img = []
    for y in range(size_y):
        row = []
        for x in range(size_x):
            row.append(get_tsubame_image(scene_id, zoom, topleft_x + x, topleft_y + y))
        img.append(np.hstack(row))
    return  np.vstack(img)

def main():
    # 新国立競技場
    zoom=18
    lat, log = 35.6796057, 139.711851
    xtile, ytile = get_tile_num(lat, log, zoom)
    
    tsubame_image = get_tsubame_image(tsubame_scenes[0]["entityId"], zoom, xtile, ytile)

    img_4x4 = get_slat_series_image(tsubame_scenes[0]["entityId"], zoom, xtile, ytile, 4, 4)
    io.imshow(img_4x4)

if __name__ == '__main__':
    main()

投稿者: admin

Free Software Engineer

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です