20
$\begingroup$

I would like some help generating an image like the one seen below.

enter image description here

The image above is an art piece called Wind Map by artists Fernanda Viégas and Martin Wattenberg.

I would like to take wind data using WeatherData and generate a map like the one above. Eventually I would like to generalize this idea to taking data from the National Digital Forecast Database.

I see that it is possible to generate a coarse wind map. When I execute that code I get the following output which is similar to what I desire, but there is still much to be done.

enter image description here

$\endgroup$
  • $\begingroup$ A couple weeks ago I was playing with a Julia script that launches a bunch of particles on a grid leaving trails behind them, and they follow a vector field defined on the grid, generating somewhat similar visual patterns as in the artwork, but it's not exactly the same method. Figuring out how the artists get their vector field and do their plotting will probably be half the work, and the rest will be figuring out how to make Mathematica give a nice-looking picture. Good luck to everyone who takes the time to answer the question! $\endgroup$ – DumpsterDoofus Nov 30 '14 at 2:49
  • $\begingroup$ Oops, never mind, they describe where they get the data and technique from in their "Read More" section. $\endgroup$ – DumpsterDoofus Nov 30 '14 at 2:52
  • 1
    $\begingroup$ You could also try LineIntegralConvolutionPlot. $\endgroup$ – Rahul Nov 30 '14 at 7:32
  • 1
    $\begingroup$ Related Q/A: (15895). $\endgroup$ – Silvia Nov 30 '14 at 14:17
17
$\begingroup$

Update

According to KennyColnago's advice, post-processing is not needed, as StreamColorFunction can handle it essentially by using VertexColors on Line-s:

ListStreamPlot[
               testdata,
               StreamPoints -> {samplePoints, Automatic, 10},
               StreamStyle -> "Line",
               Background -> Black,
               StreamColorFunction -> (GrayLevel[1, #5] &)
              ]

Original

With Simon Woods' neat trick and some post-processing:

testdata = Table[{{x, y}, RandomReal[{-1, 1}, 2]}, {x, -3, 3, 1}, {y, -3, 3, 1}] // Flatten[#,1]&;

samplePoints = Tuples[Range[-3, 3, 1/5], 2];

ListStreamPlot[
               testdata,
               StreamPoints -> {samplePoints, Automatic, 10},
               StreamStyle -> "Line",
               Background -> Black
              ] //
      # /. ln : Line[idxes_] :>
                    MapIndexed[
                               {
                                GrayLevel[1, 1 - Rescale[#2[[1]], {1, Length[idxes] - 1}]],
                                Line[#1]
                               } &,
                               Partition[idxes, 2, 1]
                              ] &

random wind map

Note for a more meaningful graphics, one might want to determine the GrayLevel according to the local wind scale.

$\endgroup$
  • 2
    $\begingroup$ Colouring according to the wind scale may be accomplished with, for example, StreamColorFunction->(ColorData["DarkRainbow",#5]&). Slot #5 corresponds to Norm[{vx,vy}]. $\endgroup$ – KennyColnago Nov 30 '14 at 17:30
  • $\begingroup$ @KennyColnago Great! Much more efficient! (Didn't realize that Line can have VertexColors too..) $\endgroup$ – Silvia Nov 30 '14 at 17:52
  • $\begingroup$ @Silvia, +1, but where' the map? $\endgroup$ – alancalvitti Dec 3 '14 at 3:39
  • $\begingroup$ @alancalvitti My apologize. Don't know why, but fetching the online data always time-out here, so I only showed the basic idea. $\endgroup$ – Silvia Dec 3 '14 at 7:13
6
$\begingroup$

I'm sure there are lots of things one might try -- here is an attempt using some of the built in options that are available in ListStreamPlot:

Show[Graphics[{Black, CountryData["USA", "Polygon"]}], 
 ListStreamPlot[
  Table[{{x, y}, 
    Through[{Cos, Sin}[
      WeatherData[{y, x}, "WindDirection"]]]}, {x, -140, -70, 5}, {y, 
    24, 50, 5}], StreamScale -> Full, StreamStyle -> "Toothpick", 
  StreamColorFunction -> GrayLevel, 
  StreamColorFunctionScaling -> False]]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ I don't know how it's done, but the original picture gives a sense of "wind direction" that is (at least for me) absent in your picture $\endgroup$ – Dr. belisarius Nov 30 '14 at 4:11
  • 1
    $\begingroup$ I see wind directions in bills picture, and it also has its own qualities. $\endgroup$ – Adrian Dec 1 '14 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.