WeatherForecastData[loc]
给出指定地点最新的天气预报,包括所有预报属性.
WeatherForecastData[prop]
给出当前位置关于指定属性的预报.
WeatherForecastData[date]
给出当前位置在由 date 指定的时间或时间段内的天气预报信息,包括所有预报属性.
WeatherForecastData[loc,prop]
给出指定位置关于属性的预报.
WeatherForecastData[loc,prop,datespec]
给出指定地点在由 datespec 表明的时间或时间段内关于指定属性的天气预报信息.
WeatherForecastData
WeatherForecastData[loc]
给出指定地点最新的天气预报,包括所有预报属性.
WeatherForecastData[prop]
给出当前位置关于指定属性的预报.
WeatherForecastData[date]
给出当前位置在由 date 指定的时间或时间段内的天气预报信息,包括所有预报属性.
WeatherForecastData[loc,prop]
给出指定位置关于属性的预报.
WeatherForecastData[loc,prop,datespec]
给出指定地点在由 datespec 表明的时间或时间段内关于指定属性的天气预报信息.
更多信息和选项
- WeatherForecastData 提供全球天气预报数据.
- WeatherForecastData[] 返回当前位置最新的天气预报,包括所有预报属性.
- WeatherForecastData[] 利用 $GeoLocation 和 $TimeZone 确定你的位置和时区.
- 可以用 ICAO 代码指定位置,例如 "KNYC",或是一个 WMO 代码,例如 "WMO12345",也可以是一个业余气象站代码,例如 "C1234",或其它标准气象站标识符.
- 还可以用经纬度坐标(缺省单位为度)、GeoPosition 规范或 Entity 对象来指定位置,假定它们表示的是带有地理坐标的对象. 另外,GeoGraphics 基元,如 GeoDisk,或用在 CityData 中的城市规范也可以用来指定位置.
- 应该用 DateObject 或 {start,end,step} 来指定date,其中,start 和 end 都是 DateObject.
- datespec 可被指定为日期列表、DateObject 或格式为 DateString 的字符串.
- WeatherForecastData 默认 datespec 由 $TimeZone 给定,除非由 DateObject 另行指定. 以 UTC 格式返回结果.
- 如果给定时间,返回的是插值后所得结果. 如果给定的是一天或更长时间段的 datespec 规范,返回该时间段对属性预报的区间值.
- datespec 可被指定为 {start,end,step},以便与 DateRange 规范相兼容. step 可以为 All 或 "Day". All 给出所有预报数据. 如果被省略,假定 step 的值为 All.
- 可用 Association["Location"->loc,"Date"datespec] 同时指定位置与日期.
- 如果给定位置,WeatherForecastData[loc,prop,datespec,func] 被用来指定输出的格式.
- func 的可能设置包括:
-
Automatic 对于区域和时间不确定的情况下,返回数值区间 Interval 对于区域和时间段,返回数值区间 Max 对于区域和时间段,返回最大值 Mean 对于区域和时间段,返回平均值 Min 对于区域和时间段,返回最小值 StandardDeviation 对于区域和时间段,返回标准方差 - 系统支持的其他参数结构包括 WeatherForecastData[loc,date]、WeatherForecastData[prop,date]、WeatherForecastData[date,prop]、WeatherForecastData[loc,func]、WeatherForecastData[loc,date,func] 和 WeatherForecastData[loc,prop,func].
- 选项 UnitSystem 可用来控制结构中的单位. 可使用下列设置:
-
"Imperial" 以英制返回结果 "Metric" 以公制返回结果 - 对于将来的数据,最多只有一个星期.
- 即时预报属性:
-
"CloudCoverFraction" 天空被云层遮蔽的比例 "Humidity" 相对湿度 "PrecipitationRate" 平均降水率 "Pressure" 大气压 "StationPressure" 压强,不计海拔 "Temperature" 温度 "WindChill" 风寒温度 "WindDirection" 风向,单位为度 "WindSpeed" 阵风风速 - 在预报时间段累积计算的属性包括:
-
"PrecipitationAmount" 降水量 "PrecipitationTypes" 预报的降水类型(冰雹、雨、雪) - 可以按 "Day" 增加进行计算的累积属性:
-
"MaxTemperature" 最高温度 "MaxWindSpeed" 最大风速 "MeanHumidity" 平均相对湿度 "MeanPressure" 平均气压 "MeanStationPressure" 平均本站气压 "MeanTemperature" 平均温度 "MeanWindChill" 平均风寒温度 "MeanWindSpeed" 平均风速 "MinTemperature" 最低温度 "TotalPrecipitation" 降水量 - WeatherForecastData 中的数据来自多个方面,包括全球预报系统 (Global Forecast System) 和北美中尺度预报系统 (North American Mesoscale Forecast System).
范例
打开所有单元 关闭所有单元基本范例 (1)
WeatherForecastData["Temperature", ["tomorrow at 3pm"]]WeatherForecastData[Entity["City", {"Miami", "Florida", "UnitedStates"}], "MaxTemperature"]["Values"]//NormalDateListPlot[WeatherForecastData["CloudCoverFraction"]]范围 (12)
位置规范 (5)
WeatherForecastData[]//ShortDateListPlot[WeatherForecastData["KBOS"]["CloudCoverFraction"]]WeatherForecastData[{40.67, -73.94}]//ShortWeatherForecastData[GeoPosition[{40.67, -73.94}]]//Short可以使用 Entity 对象:
WeatherForecastData[Entity["Dam", "HooverDam"]]//Short用自由格式输入 (
) 来获取合适的 Entity:
WeatherForecastData[["Hoover dam"]]//Shortd = WeatherForecastData[Polygon[["italy"]]]["MaxTemperature"]d["Values"]//Normal日期规范 (4)
可以用 DateObject 来输入日期:
WeatherForecastData[DateObject[Tomorrow]]["Temperature"]也可以用 DateList 格式来指定日期:
d = DateList[DateObject[Tomorrow] + Quantity[1, "Days"]]WeatherForecastData[GeoPosition[{40, -100}], "Pressure", d]以 {start,end} 格式指定日期范围将会返回该时间段内记录的所有数据:
WeatherForecastData[{DateObject[Today], DateObject[Tomorrow]}]["Humidity"]DateListPlot[%]WeatherForecastData["MeanTemperature", {Today, Tomorrow + Quantity[3, "Days"], "Day"}]DateListPlot[%]格式规范 (1)
WeatherForecastData[Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}], "MaxTemperature"]["Values"]//NormalWeatherForecastData[Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}], "MaxTemperature", Max]["Values"]//NormalWeatherForecastData[Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}], "MaxTemperature", Min]["Values"]//Normal使用设置 Mean 获取高温的平均值:
WeatherForecastData[Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}], "MaxTemperature", Mean]["Values"]//Normal关联规范 (1)
可以用 Association 同时指定位置与日期:
WeatherForecastData[<|"Location" -> GeoPosition[{45, -90}], "Date" -> Tomorrow|>]//Short选项 (2)
UnitSystem (2)
缺省情况下,用 $UnitSystem 所给格式显示结果:
$UnitSystem将 UnitSystem 设为 "Imperial" 指定单位为英寸汞柱:
WeatherForecastData["Pressure", UnitSystem -> "Imperial"]["Values"]//Normal或者将 UnitSystem 设为 "Metric" 指定单位为毫巴:
WeatherForecastData["Pressure", UnitSystem -> "Metric"]["Values"]//Normal也可用 UnitConvert 来调整单位:
UnitConvert[WeatherForecastData["Pressure"], "Atmospheres"]["Values"]//Normal应用 (4)
将某个星期平均温度的预报与之前10年同一个时间段的平均温度的进行比较:
forecast = WeatherForecastData["Temperature"]history = Table[TimeSeriesShift[AirTemperatureData[$GeoLocation, {DatePlus[forecast["FirstDate"], -Quantity[x, "Year"]], DatePlus[forecast["LastDate"], -Quantity[x, "Year"]], All}], {x, "Year"}], {x, 1, 10}];Show[
DateListPlot[history, PlotStyle -> Opacity[0.5]],
DateListPlot[TimeSeriesMap[Max, forecast], PlotStyle -> {Thick, Red}], PlotRange -> All]data = DeleteCases[{#, Total@WeatherForecastData[CountryData[#, "CapitalCity"], "TotalPrecipitation"]["Values"]}& /@ CountryData["Europe"], {_, _Missing}];rules = Rule[#[[1]], QuantityMagnitude@#[[2]]]& /@ data;GeoRegionValuePlot[rules]WeatherForecastData[GeoDisk[Entity["City", {"Champaign", "Illinois", "UnitedStates"}][EntityProperty["City", "Position"]], Quantity[100, "Miles"]], "Temperature", DateObject[Tomorrow, {12}]]WeatherForecastData[GeoDisk[Entity["City", {"SanFrancisco", "California", "UnitedStates"}][EntityProperty["City", "Position"]], Quantity[100, "Miles"]], "Temperature", DateObject[Tomorrow, {12}]]WeatherForecastData[GeoDisk[Entity["City", {"Champaign", "Illinois", "UnitedStates"}][EntityProperty["City", "Position"]], Quantity[100, "Miles"]], "Temperature", DateObject[Tomorrow, {12}], StandardDeviation]WeatherForecastData[GeoDisk[Entity["City", {"SanFrancisco", "California", "UnitedStates"}][EntityProperty["City", "Position"]], Quantity[100, "Miles"]], "Temperature", DateObject[Tomorrow, {12}], StandardDeviation]Manipulate[a = WeatherForecastData[Entity["City", {"Champaign", "Illinois", "UnitedStates"}]];
DateListPlot[TimeSeriesMap[# /. Interval[x_] :> Mean[x]&, a[g]], FrameLabel -> Automatic], {g, {"Temperature", "WindSpeed", "WindDirection", "PrecipitationAmount"}}, SaveDefinitions -> True]WeatherForecastData[Here]属性和关系 (4)
根据当地的天气预报和 FormulaData 计算低空压强:
temperature = WeatherForecastData["MeanTemperature", DateObject[Tomorrow, TimeObject[{10}]]]pressure = WeatherForecastData["MeanPressure", DateObject[Tomorrow, TimeObject[{10}]]]molarmass = Entity["Chemical", "DryAir"][EntityProperty["Chemical", "MolarMass"]];sol = FormulaData[{"BarometricFormula", "Pressure"}, {"T" -> temperature, Subscript[p, 0] -> pressure, "M" -> molarmass, "h" -> Quantity[1000, "Feet"]}]UnitConvert[sol[[2]], "Millibars"]获取天气预报信息,利用 ThermodynamicData 计算空气的密度:
range = {DateObject[Today], DateObject[Tomorrow] + Quantity[1, "Days"]};
temperatures = Normal@WeatherForecastData["Temperature", range]["Values"] /. Quantity[Interval[int_], u_] :> Quantity[Mean[int], u];
pressures = WeatherForecastData["Pressure", range];
dates = pressures["Dates"];
pressures = Normal@pressures["Values"];densities = Diagonal[ThermodynamicData["Air", "Density", {"T" -> temperatures, "P" -> pressures}]]DateListPlot[Transpose[{dates, densities}], FrameLabel -> Automatic]用 IconData 显示不同的预报属性:
forecast = WeatherForecastData[DateObject[Tomorrow, {12}]];GraphicsRow[{IconData["AirTemperature", forecast["MeanTemperature"]],
IconData["RelativeHumidity", forecast["Humidity"]],
IconData["WindSpeed", forecast["WindSpeed"]],
IconData["WindDirection", forecast["WindDirection"]]}]利用 GeoGraphics 和 IconData 显示德国境内几座城市今天最高温度的预报:
cities = {["Berlin"], ["Hamburg"], ["Munich"], ["Cologne"], ["Frankfurt"], ["Stuttgart"], ["Dortmund"], ["Bremen"], ["Dresden"], ["Hanover"], ["Nuremberg"]};data = {CityData[#, "Coordinates"], CityData[#, "Name"], First@WeatherForecastData[#, "MaxTemperature"]["Values"]}& /@ cities;GeoGraphics[{GeoStyling["ReliefMap"], EdgeForm[Thin], Opacity[0.5], Polygon[Entity["Country", "Germany"]], PointSize[Large], Opacity[1], {Black, Text[#[[2]], GeoPosition[#[[1]]], {-1.5, 0}], Red, Point[GeoPosition[#[[1]]]], Inset[IconData["AirTemperature", #[[3]]], GeoPosition[#[[1]]], Bottom, 1]}& /@ data}, RasterSize -> 200]相关指南
-
▪
- 气象数据 ▪
- 运输数据 ▪
- 地理数据和实体 ▪
- 地球科学:数据与计算
文本
Wolfram Research (2016),WeatherForecastData,Wolfram 语言函数,https://reference.wolfram.com/language/ref/WeatherForecastData.html.
CMS
Wolfram 语言. 2016. "WeatherForecastData." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/WeatherForecastData.html.
APA
Wolfram 语言. (2016). WeatherForecastData. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/WeatherForecastData.html 年
BibTeX
@misc{reference.wolfram_2026_weatherforecastdata, author="Wolfram Research", title="{WeatherForecastData}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/WeatherForecastData.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_weatherforecastdata, organization={Wolfram Research}, title={WeatherForecastData}, year={2016}, url={https://reference.wolfram.com/language/ref/WeatherForecastData.html}, note=[Accessed: 03-November-2026]}