Getting live weather conditions for a location
Objectives: Retrieve weather conditions from the live weather catalog
Complexity: Beginner
Depends on: Get your credentials, Verify Your credentials
Time to complete: 30 min
Source code: Download
The following tutorial introduces Europe and North America catalogs and shows how to get live weather conditions data using these catalogs.
The tutorial covers the following topics:
HERE live weather catalogs overview
HERE Live Weather
– Europe and North America catalogs consist of data layers with real-time Weather data. Weather attributes offered in the latest-data
volatile layer are updated every 15 minutes. Weather information is generated with the HERE Tile Level-14 resolution and stored in Level-8 partitions to optimize the performance during data transfer.
Each Level-14 HERE Tile contains the following set of information:
- Air temperature
- Dew point temperature
- Humidity
- Air pressure
- Visibility
- Precipitation type (rain, snow, ice)
- Intensity of precipitation
- Wind speed and direction
The following picture shows a Tile on zoom level 8
with Tiles on zoom level 14
that contain live weather attributes.

Run the following OLP CLI command to get the information about HERE Live Weather Europe catalog:
olp catalog show hrn:here:data:::live-weather-eu
The output should contain the following information:
Details of the hrn:here:data::olp-here:live-weather-eu catalog:
id live-weather-eu
name HERE Live Weather Europe
hrn hrn:here:data::olp-here:live-weather-eu
summary This catalog contains live weather data in Europe Weather attributes offered in a volatile catalog, updated every 15 minutes.
description This catalog contains live weather data in Europe. Weather attributes offered in a volatile catalog, updated every 15 minutes. Enabling analytics use cases.
notifications enabled? false
tags RoadWeather, Analytics, 11555WEATHER
billing tags 11555WEATHER
created 2017-11-07T21:33:11.519Z
owner HERE-f12b517c-4f08-45e8-ae8a-a317a210efdb, olp-here
config version 30
metadata version 1
metadata minimum version 0
marketplace ready false
layers
type ID name
volatile latest-data Live Weather Europe
replication
role id
primary eu-ireland
Based on the output, you can see that the HERE Live Weather Europe catalog contains only one layer called latest-data
.
Run the following OLP CLI command to get the information about the latest-data
layer of the HERE Live Weather Europe catalog:
olp catalog layer show hrn:here:data:::live-weather-eu latest-data
The output should contain the following information:
Details of the latest-data layer:
id latest-data
name Live Weather Europe
summary This layer contains the latest weather data in Europe. The weather data is refreshed every 15 minutes.
description This layer contains the latest weather data in Europe. The weather data is refreshed every 15 minutes.
Available attributes include:
- Air temperature
- Dew point temperature
- Humidity
- Air Pressure
- Visibility
- Precipitation type (rain, snow, ice)
- Intensity Of Precipitation
- Wind speed and direction
layerType volatile
partitioning heretile, tile levels: 8
partitioningScheme heretile
volume volatile
contentType application/x-protobuf
schema hrn:here:schema::olp-here:com.here.platform.schema.weather:platform-weather-schema_v1:1.0.2
tags LiveWeather, RealTimeWeather, EUWeather, 11555WEATHER
billingTags 11555WEATHER
coverage BG, AT, GI, ME, ES, SI, AD, RO, LU, IE, BE, HU, FI, NO, EE, LT, PL, CH, LV, IS, SE, HR, RS, BA, GB, FR, MT, PT, MC, LI, CZ, SK, MK, DK, NL, AL, DE
created 2017-11-07T21:41:36.672Z
volatileProperties {"dataRedundancy":"multi-instance","storageCapacityMb":2000}
ttl 604800000
Apparently, the layer is of the volatile
type which means whenever there is new data the old data is overwritten. It has the following properties:
For more information on the above properties, see Data User Guide
.
Use data schema
The data stored in the latest-data
layer is encoded using the platform-weather-schema_v1
Protobuf Schema.
The platform-weather-schema_v1
Protobuf Schema defines the Protocol Buffer messages and enumerations used by the various weather attributes in the HERE Weather catalogs. The message definitions are located in the corresponding .proto
file that describes the structure of a partition in a catalog layer.
Weather conditions are provided in form of attributes (e.g. temperature or wind) for a fine-grained location grid. To describe the location HERE uses its well-defined HERE tiling
at a level 14
. Note, such tiling is normally used to describe partitions. Here, however, it is part of the message content itself and describes the location of a weather condition. The message itself is stored in a partition at level '8' to achieve a fair ratio of payload (i.e. the weather conditions) to overhead of metadata for storing the data.
Let's look more closely at how the data is structured. At the highest level, we have the WeatherConditionPartition
message which we find in each level 8
partition. It contains the partition_name
based on HERE Tile level 8
and the list of WeatherConditionTile
objects, which hold up to 4096
locations at level 14
with weather conditions. In addition to the HERE tiling, the location is described in form of a center_point_geohash
- a unique identifier located in the center of the level 14
Tile. The time information is described by the timestamp
attribute which represents milliseconds elapsed since January 1, 1970, at 00:00:00 UTC
.
Weather conditions are represented by attributes of the following types:
- Attributes describing
air_temperature
, dew_point_temperature
, humidity
, air_pressure
, visibility
,iop
(Intensity of precipitation), pavement_temperature
, and wfd
(Water film depth) use the NumericCondition
message, that describes the estimated value of the parameter - value
attribute, confidence of the estimate - confidence
attribute, and confidence category of the estimate that can be Low
,Med
, High
- confidence_category_type
attribute . - Attribute describing
wind_velocity
uses the NumericVectorCondition
message containing the same attributes as the NumericCondition
, and having one additional direction
attribute that describes the direction of the wind. - Attribute describing
precipitation_type
uses the PrecipitationTypeCondition
message containing the above described attributes, and having one additional precipitation_type
attribute that can be UNKNOWN
by default, NONE
, Rain
or Snow
. - Attribute describing
pavement_type
uses the PavementTypeCondition
message containing the above described attributes, and having one additional pavement_condition_type
attribute that can be UNKNOWN
by default, DRY
, DAMP
, WET
, UNDERCOOLED
, SLIPPERY_FROST
, PACKED_SNOW
, BLACK_ICE
.
The following is the proto schema definition that contains the following messages:
syntax = "proto3";
package com.here.platform.schema.weather.v1;
message WeatherConditionPartition {
string partition_name = 1;
repeated WeatherConditionTile weather_condition_tile = 2;
}
message WeatherConditionTile {
sint32 tile_id = 1;
sint32 tile_level = 2;
string center_point_geohash = 3;
sint64 timestamp = 4;
NumericCondition air_temperature = 5;
NumericCondition dew_point_temperature = 6;
NumericCondition humidity = 7;
NumericCondition air_pressure = 8;
NumericCondition visibility = 9;
NumericCondition iop = 10;
NumericCondition pavement_temperature = 11;
NumericCondition wfd = 12;
NumericVectorCondition wind_velocity = 13;
PrecipitationTypeCondition precipitation_type = 14;
PavementTypeCondition pavement_type = 15;
message NumericCondition {
double value = 1;
double confidence = 2;
ConfidenceCategoryType confidence_category_type = 3;
}
message NumericVectorCondition {
double value = 1;
double direction = 2;
double confidence = 3;
ConfidenceCategoryType confidence_category_type = 4;
}
message PrecipitationTypeCondition {
PrecipitationType precipitation_type = 1;
double confidence = 2;
ConfidenceCategoryType confidence_category_type = 3;
enum PrecipitationType {
PRECIPITATION_TYPE_UNKNOWN = 0;
NONE = 1;
RAIN = 2;
SNOW = 3;
}
}
message PavementTypeCondition {
PavementConditionType pavement_condition_type = 1;
double confidence = 2;
ConfidenceCategoryType confidence_category_type = 3;
enum PavementConditionType {
PAVEMENT_CONDITION_TYPE_UNKNOWN = 0;
DRY = 1;
DAMP = 2;
WET = 3;
UNDERCOOLED = 4;
SLIPPERY_FROST = 5;
PACKED_SNOW = 6;
BLACK_ICE = 7;
}
}
enum ConfidenceCategoryType {
CONFIDENCE_CATEGORY_TYPE_UNKNOWN = 0;
HIGH = 1;
MEDIUM = 2;
LOW = 3;
}
}
For more information on message definitions, see the Weather Layer documentation.
Set up the Maven project
In order to get live weather conditions you may download the source code at the beginning of the tutorial and put them in a folder of your choice, or create a folder structure from scratch for your project:
live-weather
└── src
└── main
├── java
└── resources
└── scala
You can do this with a single bash
command:
mkdir -p live-weather/src/main/{java,resources,scala}
The Maven POM file is similar to the one in the Verify Maven Settings example, with the parent POM and dependencies sections updated:
Parent POM:
<parent>
<groupId>com.here.platform</groupId>
<artifactId>sdk-standalone-bom_2.12</artifactId>
<version>2.39.6</version>
<relativePath/>
</parent>
The following dependencies are used:
-
location-core_${scala.compat.version}
and location-integration-here-commons_${scala.compat.version}
to calculate Tile IDs -
platform-weather-schema_v1_java
to decode Partitions data -
hrn_${scala.compat.version}
to get live weather catalog hrn -
data-client_${scala.compat.version}
and data-engine_${scala.compat.version}
to download partition data.
<dependencies>
<dependency>
<groupId>com.here.platform.location</groupId>
<artifactId>location-core_${scala.compat.version}</artifactId>
<version>${location-core.version}</version>
</dependency>
<dependency>
<groupId>com.here.platform.location</groupId>
<artifactId>location-integration-here-commons_${scala.compat.version}</artifactId>
<version>${location-integration-here-commons.version}</version>
</dependency>
<dependency>
<groupId>com.here.platform.schema.weather</groupId>
<artifactId>platform-weather-schema_v1_java</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.here.hrn</groupId>
<artifactId>hrn_${scala.compat.version}</artifactId>
</dependency>
<dependency>
<groupId>com.here.platform.data.client</groupId>
<artifactId>data-client_${scala.compat.version}</artifactId>
<version>${data-client.version}</version>
</dependency>
<dependency>
<groupId>com.here.platform.data.client</groupId>
<artifactId>data-engine_${scala.compat.version}</artifactId>
<version>${data-engine.version}</version>
</dependency>
</dependencies>
Get weather conditions for a specific location
The following demonstrates how to fetch the current weather condition from the Here Live Weather Europe
catalog at a given location described with latitude
and longitude
- in this case the city center of Berlin.
The code snippet below does the following:
Step 1:
Calculate the Tile ID for the Berlin City Center coordinates on zoom level 8
using HereTileResolver
[ Java API | Scala API ] class from the Location Library. Weather information is generated with the HERE Tile on zoom level 14
resolution and stored in partitions on zoom level 8
to optimize the performance during data transfer.
Step 2:
Retrieve Partition
metadata for the obtained Tile ID on zoom level 8
using the getVolatilePartitionsAsIterator()
method from the Data Client Library.
Step 3:
Download partition for the given Berlin City Centre Tile ID on zoom level 8
using the getDataAsBytes()
method from the Data Client library.

Step 4:
Using the downloaded partition in Step 3, parse data with the platform-weather-schema_v1
Protobuf Schema.
Step 5:
Calculate the Tile ID for the Berlin City Center coordinates on zoom level 14
, where all weather conditions that we want to get are stored, using the HereTileResolver
[ Java API | Scala API ] class from the Location Library.
Step 6:
Find the weather data for Tile ID on zoom level 14
from 4096
Tiles.

import akka.actor.{ActorSystem, CoordinatedShutdown}
import com.here.hrn.HRN
import com.here.platform.data.client.common.VolatilePartitionsFilter.byIds
import com.here.platform.data.client.engine.scaladsl.{DataEngine, ReadEngine}
import com.here.platform.data.client.scaladsl.{DataClient, QueryApi}
import com.here.platform.location.core.geospatial.GeoCoordinate
import com.here.platform.location.integration.herecommons.geospatial.HereTileLevel
import com.here.platform.location.integration.herecommons.geospatial.javadsl.HereTileResolver
import com.here.platform.schema.weather.v1.PlatformWeatherSchema.WeatherConditionPartition
import scala.collection.convert.ImplicitConversions.`collection AsScalaIterable`
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{Success, Try}
object LiveWeatherExplorerSinglePointScala {
val WEATHER_TILE_LEVEL = new HereTileLevel(8)
val WEATHER_CONDITION_LEVEL = new HereTileLevel(14)
val LIVE_WEATHER_CATALOG: HRN = HRN.fromString("hrn:here:data::olp-here:live-weather-eu")
val LAYER_NAME = "latest-data"
def main(args: Array[String]): Unit = {
val actorSystem: ActorSystem = ActorSystem.create("weatherLoaderTutorial")
val queryApi: QueryApi = DataClient.get(actorSystem).queryApi(LIVE_WEATHER_CATALOG)
val readEngine: ReadEngine = DataEngine.get(actorSystem).readEngine(LIVE_WEATHER_CATALOG)
val berlinCityCentre: GeoCoordinate = new GeoCoordinate(48.15, 11.6)
val berlinTileIdOnLevelEight: Long =
new HereTileResolver(WEATHER_TILE_LEVEL).fromCoordinate(berlinCityCentre)
println(
s"Tile Id from coordinate $berlinCityCentre on Zoom Level $WEATHER_TILE_LEVEL is: $berlinTileIdOnLevelEight")
queryApi
.getVolatilePartitionsAsIterator(LAYER_NAME, byIds(Set(berlinTileIdOnLevelEight.toString)))
.onComplete({
case Success(partitionsIterator) =>
val partition = partitionsIterator.toSeq.head
readEngine
.getDataAsBytes(partition)
.onComplete({
case Success(partitionAsBytes) =>
val berlinTileIdOnLevelFourteen: Long =
new HereTileResolver(WEATHER_CONDITION_LEVEL).fromCoordinate(berlinCityCentre)
val tileConditions = for {
berlinWeatherConditions <- Try(
WeatherConditionPartition.parseFrom(partitionAsBytes)).toOption
berlinTileIdOnLevelFourteen: Long = new HereTileResolver(WEATHER_CONDITION_LEVEL)
.fromCoordinate(berlinCityCentre)
weatherData <- berlinWeatherConditions.getWeatherConditionTileList.find(
_.getTileId == berlinTileIdOnLevelFourteen)
} yield weatherData
println(
s"Tile Id from coordinate $berlinCityCentre using Zoom Level $WEATHER_CONDITION_LEVEL is: $berlinTileIdOnLevelFourteen")
println(s"Live weather around $berlinCityCentre, is $tileConditions")
CoordinatedShutdown
.get(actorSystem)
.run(CoordinatedShutdown.unknownReason)
.onComplete(print)
})
})
}
}
import akka.actor.ActorSystem;
import akka.actor.CoordinatedShutdown;
import com.google.common.collect.Iterators;
import com.google.protobuf.InvalidProtocolBufferException;
import com.here.hrn.HRN;
import com.here.platform.data.client.common.VolatilePartitionsFilter;
import com.here.platform.data.client.engine.javadsl.DataEngine;
import com.here.platform.data.client.engine.javadsl.ReadEngine;
import com.here.platform.data.client.javadsl.DataClient;
import com.here.platform.data.client.javadsl.Partition;
import com.here.platform.data.client.javadsl.QueryApi;
import com.here.platform.data.client.model.AdditionalFields;
import com.here.platform.location.core.geospatial.GeoCoordinate;
import com.here.platform.location.integration.herecommons.geospatial.HereTileLevel;
import com.here.platform.location.integration.herecommons.geospatial.javadsl.HereTileResolver;
import com.here.platform.schema.weather.v1.PlatformWeatherSchema.WeatherConditionPartition;
import com.here.platform.schema.weather.v1.PlatformWeatherSchema.WeatherConditionTile;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class LiveWeatherExplorerSinglePoint {
public static final HereTileLevel WEATHER_TILE_LEVEL = new HereTileLevel(8);
public static final HereTileLevel WEATHER_CONDITION_LEVEL = new HereTileLevel(14);
public static final HRN LIVE_WEATHER_CATALOG =
HRN.fromString("hrn:here:data::olp-here:live-weather-eu");
public static final String LAYER_NAME = "latest-data";
public static void main(String[] args) {
ActorSystem actorSystem = ActorSystem.create("weatherLoaderTutorial");
QueryApi queryApi = DataClient.get(actorSystem).queryApi(LIVE_WEATHER_CATALOG);
ReadEngine readEngine = DataEngine.get(actorSystem).readEngine(LIVE_WEATHER_CATALOG);
GeoCoordinate berlinCityCentre = new GeoCoordinate(48.15, 11.6);
long berlinTileIdOnLevelEight =
new HereTileResolver(WEATHER_TILE_LEVEL).fromCoordinate(berlinCityCentre);
System.out.printf(
"Tile ID from coordinate %s on Zoom Level %s is: %s%n",
berlinCityCentre, WEATHER_TILE_LEVEL, berlinTileIdOnLevelEight);
try {
Partition partition =
Iterators.get(
queryApi
.getVolatilePartitionsAsIterator(
LAYER_NAME,
new VolatilePartitionsFilter.Builder()
.withIds(Collections.singleton(String.valueOf(berlinTileIdOnLevelEight)))
.build(),
AdditionalFields.AllFields())
.toCompletableFuture()
.join(),
0);
byte[] downloadedPartition =
readEngine.getDataAsBytes(partition).toCompletableFuture().join();
WeatherConditionPartition berlinWeatherConditions =
WeatherConditionPartition.parseFrom(downloadedPartition);
long berlinTileIdOnLevelFourteen =
new HereTileResolver(WEATHER_CONDITION_LEVEL).fromCoordinate(berlinCityCentre);
System.out.printf(
"Tile ID from coordinate %s using Zoom Level %s is: %s%n",
berlinCityCentre, WEATHER_CONDITION_LEVEL, berlinTileIdOnLevelFourteen);
List<WeatherConditionTile> tileConditions =
berlinWeatherConditions
.getWeatherConditionTileList()
.stream()
.filter(data -> data.getTileId() == berlinTileIdOnLevelFourteen)
.collect(Collectors.toList());
System.out.printf("%nLive weather around %s, is %s%n", berlinCityCentre, tileConditions);
} catch (InvalidProtocolBufferException e) {
throw new IllegalArgumentException("Unable to parse weather data.");
} finally {
CoordinatedShutdown.get(actorSystem)
.run(CoordinatedShutdown.unknownReason(), Optional.empty())
.toCompletableFuture()
.join();
}
}
}
To execute the application, run the following command:
mvn compile exec:java -D"exec.mainClass"="LiveWeatherExplorerSinglePointScala"
mvn compile exec:java -D"exec.mainClass"="LiveWeatherExplorerSinglePoint"
According to the results of the program on Fri 22 October 2021 14:18:12
the air temperature in Berlin is 9.27°C
. Humidity
reaches 59.02%
. There is no precipitation
information as indicated by precipitation_type:None
. The confidence
of the result is 0.44 - 0.5
out of 1
, which is MEDIUM
(confidence_category_type
in the result output).
Tile ID from coordinate GeoCoordinate(48.15,11.6) on Zoom Level HereTileLevel(8) is: 92232
Tile ID from coordinate GeoCoordinate(48.15,11.6) using Zoom Level HereTileLevel(14) is: 377782527
Live weather around GeoCoordinate(48.15,11.6), is
tile_id: 377782527
tile_level: 14
center_point_geohash: "u281zy00"
timestamp: 1634912292852
air_temperature {
value: 9.27
confidence: 0.44
confidence_category_type: MEDIUM
}
humidity {
value: 59.02
confidence: 0.44
confidence_category_type: MEDIUM
}
precipitation_type {
precipitation_type: NONE
confidence: 0.5
confidence_category_type: MEDIUM
}
For better learning, you can try updating the source code to get information about the live weather conditions of your location using Europe or North America catalogs and your coordinates.
For more details on the topics covered in this tutorial, see the following sources: