Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/OdintheDoggo/GodotNWS/llms.txt

Use this file to discover all available pages before exploring further.

Observations are measured conditions reported by an actual weather station right now, as opposed to forecasts which are model-generated predictions. GodotNWS pulls the latest observation from the nearest NWS station to your configured location and packages everything into an ObservationPacket resource.
Location setup must complete before calling this method. See the Location Setup guide and wait for location_setup_complete.

Fetching Observations

Call Nws.fetch_current_observations(fetch_icon). When the data arrives, the observations_fetched signal fires with an ObservationPacket. If no observation data is available, the signal emits null instead — always check for this.
func _on_location_ready() -> void:
    Nws.observations_fetched.connect(_on_observations)
    Nws.fetch_current_observations(true)  # true = fetch condition icon

func _on_observations(obs: ObservationPacket) -> void:
    if obs == null:
        push_warning("Observations unavailable for this location.")
        return

    print("Station: ", obs.station)
    print("Reported at: ", obs.timestamp)
    print("Conditions: ", obs.textDescription)

    # Temperature is always in Celsius — convert if needed
    if obs.temperature != 0.0:
        var celsius = obs.temperature
        var fahrenheit = (celsius * 9.0 / 5.0) + 32.0
        print("Temperature: %.1f°C (%.1f°F)" % [celsius, fahrenheit])

    # Wind — check before printing, may be null/zero
    if obs.windSpeed != 0.0:
        print("Wind: %.1f m/s from %d°" % [obs.windSpeed, obs.windDirection])
    if obs.windGust != 0.0:
        print("Gusts to: %.1f m/s" % obs.windGust)

    # Humidity and dewpoint
    if obs.relativeHumidity != 0.0:
        print("Humidity: %.1f%%" % obs.relativeHumidity)
    if obs.dewpoint != 0.0:
        print("Dewpoint: %.1f°C" % obs.dewpoint)

    # Apply the icon texture if it was fetched
    if obs.icon:
        $WeatherIcon.texture = obs.icon

The fetch_icon Parameter

ValueBehaviour
trueDownloads the NWS condition icon PNG and sets obs.icon to an ImageTexture. The signal fires only after the icon arrives.
falseSkips icon download. obs.icon will be null, but obs.iconUrl contains the URL.

Temperature Units

All temperature values in an ObservationPacket — including temperature, dewpoint, windChill, heatIndex, maxTempLast24, and minTempLast24 — are provided in Celsius by the NWS API. Convert to Fahrenheit if your UI requires it:
func celsius_to_fahrenheit(c: float) -> float:
    return (c * 9.0 / 5.0) + 32.0

Null and Missing Fields

The NWS observation format is sparse — weather stations do not always report every measurement. Many fields will be 0.0 or empty if the station did not include them. Always check a value before displaying it.
func _on_observations(obs: ObservationPacket) -> void:
    if obs == null:
        return

    # Precipitation data may simply not be reported
    if obs.precipitationLastHour != 0.0:
        print("Last hour rain: %.2f mm" % obs.precipitationLastHour)
    if obs.precipitationLast3Hours != 0.0:
        print("Last 3h rain: %.2f mm" % obs.precipitationLast3Hours)
    if obs.precipitationLast6Hours != 0.0:
        print("Last 6h rain: %.2f mm" % obs.precipitationLast6Hours)

    # Pressure
    if obs.barometricPressure != 0.0:
        print("Pressure: %.0f Pa" % obs.barometricPressure)
    if obs.seaLevelPressure != 0.0:
        print("Sea-level pressure: %.0f Pa" % obs.seaLevelPressure)

    # Cloud cover
    if obs.cloudLayers != "":
        print("Cloud cover: %s at %.0f m" % [obs.cloudLayers, obs.baseCloudHeight])

The rawMessage Field

When available, obs.rawMessage contains the raw METAR string transmitted by the weather station. This is the same compact aviation weather format you see on aviation weather sites. It can be useful if you want to display or parse the unprocessed report.
if obs.rawMessage != "":
    print("METAR: ", obs.rawMessage)
# Example output: METAR KPHL 151854Z 24012KT 10SM FEW025 BKN060 18/10 A3002

ObservationPacket Fields

FieldTypeDescription
rawDictionaryThe complete raw JSON properties from the NWS API.
stationStringURL/ID of the reporting station.
timestampStringISO 8601 timestamp of the observation.
rawMessageStringRaw METAR string, if the station transmitted one.
textDescriptionStringHuman-readable condition description, e.g. "Mostly Cloudy".
iconImageTextureCondition icon image, or null.
iconUrlStringURL of the NWS condition icon, if one exists.
presentWeatherStringCurrent weather phenomenon code (e.g. "rain", "snow").
temperaturefloatAir temperature in °C.
dewpointfloatDewpoint in °C. May be 0.0 if unreported.
windDirectionfloatWind direction in degrees. May be 0.0 if calm or unreported.
windSpeedfloatWind speed in m/s. May be 0.0 if calm or unreported.
windGustfloatWind gust speed in m/s. May be 0.0 if no gusts.
barometricPressurefloatStation pressure in Pascals. May be 0.0 if unreported.
seaLevelPressurefloatSea-level pressure in Pascals. May be 0.0 if unreported.
visibilityfloatVisibility in meters. May be 0.0 if unreported.
maxTempLast24float24-hour high temperature in °C. May be 0.0.
minTempLast24float24-hour low temperature in °C. May be 0.0.
precipitationLastHourfloatPrecipitation in the last hour, in mm. May be 0.0.
precipitationLast3HoursfloatPrecipitation in the last 3 hours, in mm. May be 0.0.
precipitationLast6HoursfloatPrecipitation in the last 6 hours, in mm. May be 0.0.
relativeHumidityfloatRelative humidity as a percentage. May be 0.0 if unreported.
windChillfloatWind chill temperature in °C. May be 0.0.
heatIndexfloatHeat index in °C. May be 0.0.
cloudLayersStringCloud coverage code for the lowest layer (e.g. "FEW", "BKN", "OVC").
baseCloudHeightfloatHeight of the lowest cloud layer base in meters. May be 0.0.

Build docs developers (and LLMs) love