3

I'm a leaflet noob. I have some weather data and I'd like to display it using a leaflet map, but I'm having difficulty convincing myself that what I want to do is possible. Specifically I want to compare observed wind speed and direction with the predicted wind speed and direction. A usual way to visualize wind speed and direction is with a Wind Barb.

So there's two issues I see:
1. I need to be able draw the barb, and
2. I need to be able to rotate it to point in the correct cardinal direction.

For 1 I figure I could pre-draw some barbs for wind speeds from 5 up to say 50 every 5 units.

For 2 I would have to rotate that marker based on where it was located to point in the correct cardinal direction. This is where I get confused. Can anybody explain to me how this would be done? Is it projection dependant?

I don't suppose there's a leaflet plug-in out there that would take care of all this for me. I haven't been able to find anything thus far.

Emma Hung
  • 35
  • 1
  • 6

3 Answers3

3

I've been working on something similar. I found a pretty good looking and intuitive method being used to represent vector information. Have a look at the following examples:

http://earth.nullschool.net/

http://hint.fm/wind/

http://air.nullschool.net/

http://googlemapsmania.blogspot.com/2014/07/the-growth-of-slippy-wind-map.html

In my case, I still need to find a suitable format for the wind/ocean data I want to plot on my Leaflet map. It's certainly not a quick fix, but man, it looks great!

Maybe this can help you too. I hope to be able to post a working solution soon.

FredFury
  • 2,286
  • 1
  • 22
  • 27
  • Very Cool Fred, alas time constraints have lead me down another path. I already had a way to draw maps and wind barbs in SVG so I went that route. My maps are fixed so no fancy zoom and pan but at least I can control the visibility of layers to allow a viewer to toggle a layer on or off this is a plus since we're comparing the wind from 6 models against the observed wind. Wish I could post a link but the page isn't public. I'd love to see your final results though. – Emma Hung Dec 08 '14 at 16:59
  • It didn't solve my problem, but I bet it would be a great solution for somebody else so I'll accept it for that reason. – Emma Hung Dec 08 '14 at 17:03
2

Hopefully someone can elaborate on my answer to help you achieve your goal. I suggest looking into Open Weather Map API.
The best idea I can think of for how the flow would be is:
1.Make a call to OWM passing in the lat/long of the point clicked on the map.
2.Capture the wind speed and direction of the JSON object that is returned from OWM.
3. Determine which wind barb marker to use based on the wind speed and direction. Add it to the map.

If all else fails, OWM does have a 'wind' tilelayer you can use to show wind data. Good luck.

Ju66ernaut
  • 2,592
  • 3
  • 23
  • 36
  • Thanks, Chris. I've got my own wind data that I'm trying to verify. It's experimental and thus not openly available. I am considering trying to see if I can use MapServer to serve up the model winds at least. I'll look into Open Weather Map again though. – Emma Hung Sep 26 '14 at 13:06
2

I know this is an old question, but this might still be useful for someone. I had the same general problem: I wanted to display wind speeds and directions using the standard wind barbs. I found no useful plugin for Leaflet so I created my own.

The plugin takes input data in form of speed in knots (nautical miles (1.852 km) per hour) and direction in degrees. It then generates the wind barbs and outputs an icon. This icon can easily be added to a Leaflet marker.

You can download it here: https://github.com/JoranBeaufort/Leaflet.windbarb And you can see a live example here: http://www.geonet.ch/leaflet-windbarb/

I hope this helps you or someone with similar needs. Cheers

Mfbaer
  • 465
  • 3
  • 15
  • Wow, that's pretty cool alas the project i needed this for ended last summer, but I will keep this in mind if I ever have to go down this road again. – Emma Hung Jun 06 '16 at 18:14