0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GoogleDataPotalで緯度経度データからMapを作成

Posted at

PostgreSQLでgeometry(緯度経度)として管理しているデータをGoogleDataPotalのMapとして作成する方法をまとめる。

やりたいこと

  • DBデータをGoogleMapに反映させる
  • 拡大縮小に併せて表示領域も変化する

完成イメージ↓
image.png

準備:GoogleDataPotalで扱う「緯度経度」形式の変換

DBではgeometoryとして管理

select geopoint from data;
=> geopoint: "0101000020E6100000F42FEEAB1751444031F9556F03976140"

GoogleDataPotalでの「緯度,経度」の形式にする
select concat(ST_X(geopoint), ',', ST_Y(geopoint)) AS geo from data;

=> geo: "40.6335349,140.7191693"

GoogleDataPotalのデータソースで緯度経度として取り込む

  • 上記の形式変換が必要なので、「Custom Query」としてSQLを書いて取り込む
  • カラムの種別を「緯度、経度」に設定する(画像)

image.png

GooleDataPotalでマップを作成

  • グラフ->GoogleMap->「バブルマップ」を選択
  • 下の画像を参考に情報を設定

image.png

最後に

  • ざっと漁った限りだと、緯度経度の形式とか書いてなくて手探りで試したので共有しました。
  • 他のMapとかアメリカだと州ごと設定できるけど、日本含め他の国は対応してなさそう。
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?