NB I think there's a problem with this code, please see this answer by ubpdqn for more information. I'll update these snippets when I get the chance.
Yours is a question with many possible interpretations. I've chosen the interpretation that was most fun for me to play with, so...
ang = 20; (* divide the world into chunks of this size *)
pts = Flatten[Table[{lat, long}, {lat, -80, 80, ang}, {long, -180, 180, ang}], 1];
sample = WindVectorData[Replace[pts, c_ :> {c, Today}, 1]]; (* this takes forever *)
stream = Cases[Transpose@{Reverse/@pts, sample}, {_, Except[_Missing]}] /.
Quantity[v_, _] :> v /. Interval[lst_] :> Mean /@ lst;
(* This function crashes kernel very often, but in interpolation, I assume *)
streamplot = ListStreamPlot[stream, StreamColorFunction -> "SolarColors",
InterpolationOrder -> None, StreamPoints -> Fine];
mpoly[poly_] := poly /. GeoPosition[pts_] :> pts
/. {lat_Real, long_} :> {long, lat}
/. Polygon[data_] :> Style[Polygon[data], Antialiasing -> True];
world = Graphics[{RGBColor[0.38, 0.77, 1.]}~Join~
Table[mpoly@CountryData[c, "SchematicPolygon"], {c, CountryData[]}]];
g = Show[world, streamplot, ImageSize -> 1400]
If you have Mathematica 10, the graph g
should be:
Puting it together, you can have a function like
PlotWindBox[country_String, date_, n_] :=
Module[{box, latmin, latmax, longmin, longmax, pts, sample, stream,
streamplot, mpoly, target, world, latstep, longstep},
box = {Min@#, Max@#} & /@
Transpose@
Cases[CountryData[country, "Polygon"], {_Real, _}, Infinity];
{{latmin, latmax}, {longmin, longmax}} = box + {{-2, 2}, {-2, 2}};
latstep = (latmax - latmin)/(n - 1);
longstep = (longmax - longmin)/(n - 1);
pts = Flatten[
Table[{lat, long}, {lat, latmin, latmax, latstep}, {long,
longmin, longmax, longstep}], 1];
sample = WindVectorData[Replace[pts, c_ :> {c, date}, 1]];
stream =
Cases[Transpose@{Reverse /@ pts, sample}, {_,
Except[_Missing]}] /. Quantity[v_, _] :> v /.
Interval[lst_] :> Mean /@ lst;
streamplot =
ListStreamPlot[stream, StreamColorFunction -> "SolarColors",
StreamPoints -> Fine, InterpolationOrder -> None];
mpoly[poly_] :=
poly /.
GeoPosition[pts_] :> pts /. {lat_Real, long_} :> {long,
lat} /. Polygon[data_] :>
Style[Polygon[data], Antialiasing -> True];
target =
Graphics[{RGBColor[0.38, 0.77, 1.],
mpoly@CountryData[country, "Polygon"]}];
world =
Graphics[{GrayLevel[0.84]}~Join~
Table[mpoly@CountryData[c, "Polygon"], {c,
Cases[CountryData[], Except[Entity["Country", country]]]}]];
Show[world, target, streamplot, ImageSize -> 1400,
PlotRange -> {{longmin, longmax}, {latmin, latmax}}]
];
Call it with PlotWindBox["Australia", Today, 10]
(10 means that there are 10^2 sample points, try with fewer sample points if you are impatient like me) and obtain:
GeoGraphics
in version 10 can be used for map but requires some work to get the vector plot as you cannot combine withShow
. However, you can useCountryData["Australia","Schematic Polygon"]
. With respect to the removal of missing data, there are two issues. In v 10 the above produces things with units so need to stripQuantityMagnitude
and probably easier to doCases
where data all numeric. $\endgroup$