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 を管理する) Google Cloud アカウント(Cloud コンソールで作成)(Earth Engine Solar API を有効にする)
公開 アクセス制御
レベル セルフプロビジョニング Cloud プロジェクトの手動アクセス
認証 API キーと OAuth API キー
料金
戦略 Pay-as-you-go 100% 割引
階層化 クエリ 1, 000 件あたり、ボリュームに応じて料金を引き下げ
エンドポイント エンドポイントごとに異なる料金
クラウド
モニタリング [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)
メソッド
  • buildingInsights:findClosest
  • dataLayers:get
  • buildings:findClosest
  • solar.get
レスポンス パイロット版からの変更なし
solarInfo 半径 100 m 以下 半径 100 m 以下
サポート範囲
地域 グローバル グローバル
データ品質 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 を使用する

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

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

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 利用規約