Write a post

Enjoy this post? Give Dmitry Vasilev a like if it's helpful.

Mixing Flight Tickets Data with Weather Data

Published Feb 16, 2017Last updated Feb 21, 2017
Mixing Flight Tickets Data with Weather Data

Hi, Codementor community!😃

Once upon a time I had some spare time in the weekend and decided to make some pet-project/micro-hackathon for myself. There had been no sunny weather in Moscow for a couple of months when I decided to do that. Therefore, I decided to look into it!
tickets and weather

This is how I did it:

  • Step 1: I parced city coordinates from map.aviasales.ru

  • Step 2: I enriched it with the weather data taken from openweathermap.org.

  • Step 3: I plotted it on google maps as a heatmap!
    1.png
    Looks pretty...but, it's not very useful - color distribution was affected by the dots closeness, not by their temperature.

  • Step 4: I tried to plot it as colored circles where the colors were calculated as a HSL gradient.
    2.png
    It looks fine too, but was a bit too laggy with 3K points.

For such cases google maps have a cool feature currently is alpha-version - Fusion Tables.

  • Step 5: I uploaded my data to it, plotted - super, not lags.
    3.png

Fusion Tables web-interface also allows you to customize markers for data ranges. It wasn't too flexible, maybe that's because of alpha-state — there are also hacky workarounds in JS but that's enough for me now!

4.png

  • Step 6: I parsed map.aviasales.ru again for the round-trip tickets prices, then filtered results slightly:
places = [place for place in Place.objects.all() if 17 <= place.weather['temp'] < 25 and place.price and place.price < 20000]
  • Step 7: with an ugly JS, I added it as a second layer of custom markers to the map:
    5.png

  • Step 8: I wrapped the whole project with Docker (django, uwsgi, nginx, postgres in a single container) and rolled it out on my VPS in Netherlands!

That' it! 😃

To view the result, visit: http://catchthesummer.scythargon.ru

sources: https://github.com/scythargon/catch_the_summer

Time spent: less than 15 hours

Pity that aviasales.ru/calendar does not accept GET-parameters:)

Any comments are very welcomed!

Discover and read more posts from Dmitry Vasilev
get started
Enjoy this post?

Leave a like and comment for Dmitry

Subscribe to our weekly newsletter