Stay organized with collections Save and categorize content based on your preferences.
Use raster data to analyze temperaturePreview
This product or feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. Pre-GA products and features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
This tutorial describes how to perform geospatial analysis on raster data.
ObjectivesST_REGIONSTATS
function to calculate the average temperature in each country at a point in time.In this tutorial, you use the following billable components of Google Cloud:
Before you beginWe recommend that you create a Google Cloud project for this tutorial. Make sure that you have the required roles to complete this tutorial.
Set up a Google Cloud projectIn the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
Enable the BigQuery, BigQuery sharing, and Google Earth Engine APIs.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Verify that billing is enabled for your Google Cloud project.
Enable the BigQuery, BigQuery sharing, and Google Earth Engine APIs.
To get the permissions that you need to perform the tasks in this tutorial, ask your administrator to grant you the following IAM roles on your project:
roles/earthengine.viewer
)roles/serviceusage.serviceUsageConsumer
)roles/bigquery.dataEditor
)For more information about granting roles, see Manage access to projects, folders, and organizations.
These predefined roles contain the permissions required to perform the tasks in this tutorial. To see the exact permissions that are required, expand the Required permissions section:
Required permissionsThe following permissions are required to perform the tasks in this tutorial:
earthengine.computations.create
serviceusage.services.use
bigquery.datasets.create
You might also be able to get these permissions with custom roles or other predefined roles.
Subscribe to a datasetTo find the dataset used for this tutorial, follow these steps:
Go to the Sharing (Analytics Hub) page.
Click search Search listings.
In the Search for listings field, enter "ERA5-Land Daily Aggregated"
.
Click the result. A details pane opens with information about the ERA5-Land climate reanalysis dataset, including a description, a link to band information, the availability, the pixel size, and the terms of use.
Click Subscribe.
Optional: Update the Project.
Update the Linked dataset name to era5_climate_tutorial
.
Click Save. The linked dataset is added to your project and contains a single table called climate
.
Each row in the era5_climate_tutorial.climate
table contains metadata for a raster image that has climate data for a particular day. Run the following query to extract the raster ID of the raster image for January 1, 2025:
SELECT
assets.image.href
FROM
`era5_climate_tutorial.climate`
WHERE
properties.start_datetime = '2025-01-01';
The result is ee://ECMWF/ERA5_LAND/DAILY_AGGR/20250101
. In the next section, you use this for the raster_id
argument to the ST_REGIONSTATS
function.
Run the following query to compute the average temperature of each country on January 1, 2025 using the ST_REGIONSTATS
function:
WITH SimplifiedCountries AS (
SELECT
ST_SIMPLIFY(geometry, 10000) AS simplified_geometry,
names.primary AS name
FROM
`bigquery-public-data.overture_maps.division_area`
WHERE
subtype = 'country'
)
SELECT
sc.simplified_geometry AS geometry,
sc.name,
ST_REGIONSTATS(
sc.simplified_geometry,
'ee://ECMWF/ERA5_LAND/DAILY_AGGR/20250101',
'temperature_2m'
).mean - 273.15 AS mean_temperature
FROM
SimplifiedCountries AS sc
ORDER BY
mean_temperature DESC;
This query runs on the publicly available division_area
table that contains GEOGRAPHY
values representing the boundaries of various regions on Earth, including countries. The ST_REGIONSTATS
function uses the temerature_2m
band of the raster image, which contains the temperature of the air at 2 meters above the surface of the land at the given pixel.
To visualize your results in BigQuery, follow these steps:
In the Query results pane, click the Visualization tab.
For Data column, select mean_temperature
.
A world map appears, styled by a color gradient for the average temperature of each country.
You can also visualize your results using BigQuery Geo Viz.
Launch Geo Viz and authenticateBefore using Geo Viz, you must authenticate and grant access to data in BigQuery.
To set up Geo Viz, do the following:
Open the Geo Viz web tool.
Alternatively, in the Query results pane, click Open in > GeoViz.
In step one, Query, click Authorize.
In the Choose an account dialog, click your Google Account.
In the access dialog, click Allow to give Geo Viz access to your BigQuery data.
After you authenticate and grant access, the next step is to run the query in Geo Viz.
To run the query, do the following:
For step one, Select data, enter your project ID in the Project ID field.
In the query window, enter the following GoogleSQL query. If you opened Geo Viz from your query results, this field is already populated with your query.
WITH SimplifiedCountries AS (
SELECT
ST_SIMPLIFY(geometry, 10000) AS simplified_geometry,
names.primary AS name
FROM
`bigquery-public-data.overture_maps.division_area`
WHERE
subtype = 'country'
)
SELECT
sc.simplified_geometry AS geometry,
sc.name,
ST_REGIONSTATS(
sc.simplified_geometry,
'ee://ECMWF/ERA5_LAND/DAILY_AGGR/20250101',
'temperature_2m'
).mean - 273.15 AS mean_temperature
FROM
SimplifiedCountries AS sc
ORDER BY
mean_temperature DESC;
Click Run.
The Style section provides a list of visual styles for customization. For more information about each style, see Format your visualization.
To format your map, do the following:
To open the fillColor panel, click step 3, Style.
Click the Data-driven toggle to the on position.
For Function, choose linear.
For Field, choose mean_temperature
.
For Domain, enter -20
in the first box and 32
in the second box.
For Range, click the first box and enter #0006ff
in the Hex box, and then click the second box and enter #ff0000
. This changes the color of each country based on its average temperature on January 1, 2025. Blue indicates a colder temperature and red indicates a warmer temperature.
Click fillOpacity.
In the Value field, enter .5
.
Click Apply style.
Examine your map. If you click a country, the country's name, average temperature, and simplified geometry are displayed.
appspot.com
URL, delete selected resources inside the project instead of deleting the whole project.If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects can help you avoid exceeding project quota limits.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4