Google Maps Platform で Solar API に移行する

Google Earth Engine Solar API から Google Maps Platform Solar API に移行するには:

  1. クラウド プロジェクトで Google Maps Platform Solar API を有効にします。
  2. 新しいキーを作成し、GMP Solar API に制限します。
  3. 以下の手順に沿ってコードを更新します。

横並びでの比較

Solar API(新規)太陽のある家 Earth Engine Solar API(非推奨)EE アイコン
リリース ステータス リリース済み パイロット(非推奨)
アクセス
メカニズム Cloud コンソールから Google Cloud アカウント(Solar API を有効にし、Google Maps Platform セクションで API を管理) Cloud コンソールから Google Cloud アカウント(Earth Engine Solar API を有効化)
誰が パブリック アクセス制御
レベル セルフ プロビジョニング Cloud プロジェクトの手動アクセス
認証 API キーと OAuth API キー
料金
戦略 Pay-as-you-go 100% 割引
階層化 クエリ 1, 000 件あたり、ボリュームに応じて値下げ
エンドポイント エンドポイントごとに異なる料金
Cloud
モニタリング [Google Maps Platform] の下の [Cloud Monitoring] [API とサービス] の下の Cloud Monitoring
割り当て QPM(1 分あたりのクエリ数)と QPH(1 時間あたりのクエリ数) 年単位
ロギング Cloud Logging(オプション) Cloud Logging(オプション)
請求 Cloud 請求先アカウントの作成、変更、閉鎖 -
サポート SLO/SLA を含む Google Maps Platform のフルサポート 限定公開(メール経由)
API
ホスト名 https://solar.googleapis.com/v1/(REST) https://earthenginesolar.googleapis.com/v1/(REST)
Methods
  • buildingInsights:findClosest
  • dataLayers:get
  • buildings:findClosest
  • solar.get
レスポンス パイロット版から変更なし
solarInfo 半径 100 m 以下 半径 100 m 以下
カバー率
領域 Global Global
データ品質 HIGH/MEDIUM HIGH/MEDIUM
建物の種類 住所にマッピングされ、Solar API 画像範囲内にある建物 住所にマッピングされ、Solar API 画像範囲内にある建物
利用規約
TOS Google Maps Platform 利用規約 Google Earth Engine 利用規約

詳細な手順

Google Cloud プロジェクトをセットアップする

手順については、Google Cloud プロジェクトを設定するをご覧ください。

Cloud プロジェクトを作成できるのは特定のロールのみです。プロジェクトを作成できない場合は、組織の管理者にお問い合わせください。

既存の Cloud プロジェクトを使用することもできます。詳しくは、Google Maps Platform スタートガイドをご覧ください。

請求先アカウントの設定

手順については、請求先アカウントを管理する方法をご覧ください。

既存の請求先アカウントで既存の Cloud プロジェクトを使用できます。

API キーを取得する、または OAuth トークンを使用する

Google Cloud プロジェクトを設定したら、API キーを使用するで説明されているように、Solar API を使用するために API キーを作成して保護する必要があります。または、OAuth を使用するの説明に従って OAuth トークンを作成できます。

Solar API を使用する

  • 新しいエンドポイント https://solar.googleapis.com に GET リクエストを送信します。
  • 以下の API メソッド名が一部変更されています。
    • buildings:findClosestbuildingInsights:findClosest
    • solarinfo:getdataLayers:get

クイック トライアル: 前のステップで保存した API キーを使用し、以下のクエリ例の YOUR_API_KEY を置き換えてから、ブラウザに URL を読み込みます。

https://solar.googleapis.com/v1/dataLayers:get?location.latitude=37.2746464&location.longitude=-121.7530949&radius_meters=10&key=YOUR_API_KEY

元のプレビュー リリースに対するレスポンス

2023 年 5 月 9 日の元のプレビュー リリースでは、レスポンスの URL は次の形式になります。

https://earthengine.googleapis.com/v1alpha/projects/sunroof-api/thumbnails/THUMBNAIL_ID:getPixels

次のスニペットは、レスポンスの例です。

{
  "imageryDate": {
    "year": 2015,
    "month": 8,
    "day": 8
  },
  "imageryProcessedDate": {
    "year": 2021,
    "month": 2,
    "day": 15
  },
  "dsmUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/fbde33e9cd16d5fd10d19a19dc580bc1-8614f599c5c264553f821cd034d5cf32:getPixels",
  "rgbUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/91ed3551f2d0abee20af35e07bd0c927-c96c59e80cf1fc1dc86cf59fc8ec86ba:getPixels",
  "maskUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/e4051553dba6870c03d855ae82c30b7e-7cc8ae6ce7c73f219e3c1924e5c17fc6:getPixels",
  "annualFluxUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/9b0f87f49d778a65c9e27ff936e6dbba-b90be2fe80d25abd4c9e8c4dc809f763:getPixels",
  "monthlyFluxUrl": "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/90e7cca77402f14809e349937f0a0be8-94fafeb4ef42d72f1b3c0652a1cb5518:getPixels",
  "hourlyShadeUrls": [
    "https://earthengine.googleapis.com/v1alpha/projects/geo-solar-api/thumbnails/dcd276e4782aef4ff1b230b781736d37-e193b231ce57a03449afc3e21cf6783b:getPixels",
    ...
  ]
  }

レスポンスの URL にリクエストを送信するには、リクエストに URL 全体を含めます。

このリクエストとレスポンスの詳細な仕様については、リファレンス ドキュメントをご覧ください。

両方のレスポンス形式をサポートするアプリを作成する

これで、元のプレビュー形式と現在のレスポンス形式の両方を処理するアプリを作成できるようになりました。

2 つのレスポンスの主な違いは、実際の URL 自体を除き、新しいレスポンス形式の URL にアクセスするリクエストに API キーを渡す必要があることです。API キーを省略すると、リクエストは失敗します。

たとえば、アプリに次のコードを追加すると、URL を調べて各バージョンを正しく処理できます。

JavaScript

/**
* Function to examine a response URL and to append the API key to the
* URL if it is in the new format.
*/
function prepareGetGeoTiffUrl(geoTiffUrl, apiKey) {
  if (geoTiffUrl.match("solar.googleapis.com")) {
    let url = new URL(geoTiffUrl);
    url.searchParams.set('apiKey', apiKey);
    return url.toString();
  }
  return geoTiffUrl;
}

Python

# Functions to examine a response URL and to append the API key to the
# URL if it is in the new format.

def add_api_key_to_url(base_url: str, api_key: str) -> str:
  '''Formats URL that currently lacks an API key to use the one provided.'''
  return base_url + "&key=" +api_key;

def prepare_geo_tiff_url(base_url: str, api_key: str) -> str:
  '''Prepares URL from GetDataLayers depending on API being called.
    If the geoTIFF url from GetDataLayers is for the solar API GetGeoTiff
      endpoint, append the API key. Otherwise return the URL as is.
  '''
  if re.search("solar.googleapis.com", geo_tiff_url):
    return add_api_key_to_url(geo_tiff_url, api_key)
  return geo_tiff_url

Java


/** Adds API key to a URL. */
private String addApiKeyToUrl(String geoTiffUrl, String apiKey) {
  return geoTiffUrl + "&key=" + apiKey;
}

/**
* Function to examine a response URL and to append the API key to the
* URL if it is in the new format.
*/
private String prepareGetGeoTiffUrl(String geoTiffUrl, String apiKey) {
  Pattern pattern = Pattern.compile("solar.googleapis.com");
  Matcher matcher = pattern.matcher(geoTiffUrl);
  if (matcher.find()) {
    return addApiKeyToUrl(geoTiffUrl, apiKey);
  } else {
    return geoTiffUrl;
  }
}

モニタリング

プロジェクト レベル 請求先アカウント レベル

Cloud Monitoring Cloud Billing

役立つヒント

  • 割り当て: スケーリング可能な使用量(年間ではなく、今後なくなる)
    • 現在の割り当ては QPM に変更されます。
    • ベスト プラクティス: クライアントサイドの割り当ての設定とアラートの送信
  • 料金:
    • Pay-as-you-go
    • ロケーションがカバレッジ範囲内にない場合、404 NOT_FOUND レスポンスは課金されませんが、割り当てに対してカウントされます。
  • 一般的な使用条件: Google Maps Platform 利用規約