1
1

More than 3 years have passed since last update.

Pythonで3次メッシュコードをWKTに変換する

Last updated at Posted at 2019-12-07

備忘録レベルですが、pythonで3次メッシュコードをWKTに変換する関数を作成いたしました。
地味ですが、いざ必要なときに計算できなくなってしまいがちです...


def toWKTfromMeshCode3(mcode3: 'mesh code(str)'):-> 'wkt(str)'
  south = (int(mcode3[0:2]) * 80 + int(mcode3[4:5]) * 10 + (int(mcode3[6:7]))) * 30 / 3600
  west = (int(mcode3[2:4]) * 80 + int(mcode3[5:6]) * 10 + (int(mcode3[7:8]))) * 45 / 3600 + 100
  north = south + 30 / 3600
  east = west + 45 / 3600
  wkt = 'POLYGON(({e} {n},{w} {n},{w} {s},{e} {s},{e} {n}))'.format(s=south, w=west, n=north, e=east)
  return wkt

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1