Make a data layers request

  • The dataLayers endpoint provides downloadable TIFF files containing detailed solar information for a specified location and radius.

  • Request parameters include location coordinates, radius, data subsets, minimum quality, and pixel scale.

  • The response provides URLs to access GeoTIFF files containing solar data, such as DSM, RGB imagery, and solar flux.

  • These URLs require authentication (API key or OAuth token) and are active for one hour.

  • To view the data, import the TIFF files into mapping software like QGIS, as most will appear blank in standard image viewers.

European Economic Area (EEA) developers

The dataLayers endpoint provides detailed solar information for a region surrounding a specified location. The endpoint returns 17 downloadable TIFF files, including:

  • Digital surface model (DSM)
  • RGB composite layer (aerial or satellite imagery)
  • A mask layer that identifies the boundaries of the analysis
  • Annual solar flux, or the annual yield of a given surface
  • Monthly solar flux, or the monthly yield of a given surface
  • Hourly shade (24 hours)

For more information about how the Solar API defines flux, see Solar API Concepts.

About data layers requests

The following example shows the URL of a REST request to the dataLayers method:

https://solar.googleapis.com/v1/dataLayers:get?parameters

Include your request URL parameters that specify the following:

  • Latitude and longitude coordinates of the location
  • The radius of the region surrounding the location
  • The subset of the data to return (DSM, RGB, mask, annual flux, or monthly flux)
  • The minimum quality allowed in the results
  • The minimum scale of data to return, in meters per pixels

Example data layers request

The following example requests all building insights information in a 100 meter radius for the location at the coordinates of latitude = 37.4450 and longitude = -122.1390:

API key

To make a request to the URL in the response, append your API key to the URL:

curl -X GET "https://solar.googleapis.com/v1/dataLayers:get?location.latitude=37.4450&location.longitude=-122.1390&radiusMeters=100&view=FULL_LAYERS&requiredQuality=HIGH&exactQualityRequired=true&pixelSizeMeters=0.5&key=YOUR_API_KEY"

You can also make HTTP requests by pasting the URL in the cURL request into your browser's URL bar. Passing the API key provides you with better usage and analytics capabilities and better access control to the response data.

OAuth token

Note: This format is for a testing environment only. For more information, see Use OAuth.

To make a request to the URL in the response, pass in your billing project name and your OAuth token:

curl -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "X-Goog-User-Project: PROJECT_NUMBER_OR_ID" \
  "https://solar.googleapis.com/v1/dataLayers:get?location.latitude=37.4450&location.longitude=-122.1390&radius_meters=100&required_quality=HIGH&exactQualityRequired=true"
        

TypeScript

To make a request to the URL in the response, include either your API key or the OAuth token in the request. The following example uses an API key:

/**
 * Fetches the data layers information from the Solar API.
 *   https://developers.google.com/maps/documentation/solar/data-layers
 *
 * @param  {LatLng} location      Point of interest as latitude longitude.
 * @param  {number} radiusMeters  Radius of the data layer size in meters.
 * @param  {string} apiKey        Google Cloud API key.
 * @return {Promise<DataLayersResponse>}  Data Layers response.
 */
export async function getDataLayerUrls(
  location: LatLng,
  radiusMeters: number,
  apiKey: string,
): Promise<DataLayersResponse> {
  const args = {
    'location.latitude': location.latitude.toFixed(5),
    'location.longitude': location.longitude.toFixed(5),
    radius_meters: radiusMeters.toString(),
    // The Solar API always returns the highest quality imagery available.
    // By default the API asks for HIGH quality, which means that HIGH quality isn't available,
    // but there is an existing MEDIUM or BASE quality, it won't return anything.
    // Here we ask for *at least* BASE quality, but if there's a higher quality available,
    // the Solar API will return us the highest quality available.
    required_quality: 'BASE',
  };
  console.log('GET dataLayers\n', args);
  const params = new URLSearchParams({ ...args, key: apiKey });
  // https://developers.google.com/maps/documentation/solar/reference/rest/v1/dataLayers/get
  return fetch(`https://solar.googleapis.com/v1/dataLayers:get?${params}`).then(
    async (response) => {
      const content = await response.json();
      if (response.status != 200) {
        console.error('getDataLayerUrls\n', content);
        throw content;
      }
      console.log('dataLayersResponse', content);
      return content;
    },
  );
}

Fields and type of data is a "type" in TypeScript. In this example, we define a custom type to store the fields of interest in the response, such as the pixel values and the lat/long bounding box. You can include more fields as desired.

export interface GeoTiff {
  width: number;
  height: number;
  rasters: Array<number>[];
  bounds: Bounds;
}

Data type definitions

The following data types are supported:

export interface DataLayersResponse {
  imageryDate: Date;
  imageryProcessedDate: Date;
  dsmUrl: string;
  rgbUrl: string;
  maskUrl: string;
  annualFluxUrl: string;
  monthlyFluxUrl: string;
  hourlyShadeUrls: string[];
  imageryQuality: 'HIGH' | 'MEDIUM' | 'BASE';
}

export interface Bounds {
  north: number;
  south: number;
  east: number;
  west: number;
}

// https://developers.google.com/maps/documentation/solar/reference/rest/v1/buildingInsights/findClosest
export interface BuildingInsightsResponse {
  name: string;
  center: LatLng;
  boundingBox: LatLngBox;
  imageryDate: Date;
  imageryProcessedDate: Date;
  postalCode: string;
  administrativeArea: string;
  statisticalArea: string;
  regionCode: string;
  solarPotential: SolarPotential;
  imageryQuality: 'HIGH' | 'MEDIUM' | 'BASE';
}

export interface SolarPotential {
  maxArrayPanelsCount: number;
  panelCapacityWatts: number;
  panelHeightMeters: number;
  panelWidthMeters: number;
  panelLifetimeYears: number;
  maxArrayAreaMeters2: number;
  maxSunshineHoursPerYear: number;
  carbonOffsetFactorKgPerMwh: number;
  wholeRoofStats: SizeAndSunshineStats;
  buildingStats: SizeAndSunshineStats;
  roofSegmentStats: RoofSegmentSizeAndSunshineStats[];
  solarPanels: SolarPanel[];
  solarPanelConfigs: SolarPanelConfig[];
  financialAnalyses: object;
}

export interface SizeAndSunshineStats {
  areaMeters2: number;
  sunshineQuantiles: number[];
  groundAreaMeters2: number;
}

export interface RoofSegmentSizeAndSunshineStats {
  pitchDegrees: number;
  azimuthDegrees: number;
  stats: SizeAndSunshineStats;
  center: LatLng;
  boundingBox: LatLngBox;
  planeHeightAtCenterMeters: number;
}

export interface SolarPanel {
  center: LatLng;
  orientation: 'LANDSCAPE' | 'PORTRAIT';
  segmentIndex: number;
  yearlyEnergyDcKwh: number;
}

export interface SolarPanelConfig {
  panelsCount: number;
  yearlyEnergyDcKwh: number;
  roofSegmentSummaries: RoofSegmentSummary[];
}

export interface RoofSegmentSummary {
  pitchDegrees: number;
  azimuthDegrees: number;
  panelsCount: number;
  yearlyEnergyDcKwh