Message Boards Message Boards

Temperature simulation using WeatherStation

Posted 2 years ago

Dear friend, I try to find a code to estimate the temperature in any coordinate of a country or region using the weather station information. Here it is an example for Italy, however some thing is wrong. Any help

stations = GeoEntities[Entity["Country", "Italy"], "WeatherStation"];

locs = DeleteMissing[Through[stations["Position"]]];

temp = DeleteMissing[AirTemperatureData /@ stations];

PointValuePlot[locs -> temp, ColorFunction -> "Rainbow"]

sf = SpatialEstimate[locs -> temp]

sf[{45, 10}]
2 Replies

Guillermo,

this might be a start:

stations = GeoEntities[Entity["Country", "Italy"], "WeatherStation"];
(* the data: *)
stationsData0 = Quiet[{#, #["Position"], AirTemperatureData[#]} & /@ stations];
(* data without "Missing[]" *)
stationsData = DeleteMissing[stationsData, 1, Infinity];

GeoDensityPlot[stationsData[[All, 2]] -> stationsData[[All, 3]], 
 ColorFunction -> "Rainbow", RegionFunction -> Entity["Country", "Italy"], GeoBackground -> None, 
 PlotLegends -> Automatic]

enter image description here

I guess that SpatialEstimate does not digest GeoPosition data; I would use cartesian coordinates (like UTM, i.e. their numeric values).

Addendum - @Rohit Namjoshi: I saw your post too late, sorry! Interestingly this works with units:

sf = SpatialEstimate[Identity @@@ stationsData1[[All, 2]] -> stationsData1[[All, 3]]]

but then the number which is given back seems to be the temperature in Kelvin:

enter image description here

Really strange!

POSTED BY: Henrik Schachner
Posted 2 years ago

The documentation states that the locations can be GeoPosition and the values can be Quantity, but it does not work for your example. This does

sf = SpatialEstimate[(locs /. GeoPosition -> Identity) -> QuantityMagnitude@temp]

sf[{45, 10}]
(* 39.1 *)

This seems like a bug to me, you should report it to Wolfram Support.

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract