data-8 / datascience

A Python library for introductory data science
https://www.data8.org/datascience/
BSD 3-Clause "New" or "Revised" License
623 stars 294 forks source link

Feature request: way to create a heat map from a Table of (lat,long) points #69

Closed davidwagner closed 5 years ago

davidwagner commented 9 years ago

It would be nice if the Map class provided a way to overlay a heat map on top of a map: given a large collection of (lat,long) points (e.g., Markers), construct a heat map making it easy to visualize where the points are most concentrated.

Maybe there's an easy way by using the options provided, but I couldn't figure out how to do that from the public documentation. Maybe provide an API for this, or document how to do it? I bet this will be a useful thing for students -- and I'd like to use it for Friday lecture too.

papajohn commented 9 years ago

There's no heatmap support in the mapping library we're using, as far as I can tell. You can draw a bunch of transparent circles, which gives a similar effect — opacity is a measure of concentration.

For example, the parcels of Berkeley vaguely look like a heat map:

screen shot 2015-09-17 at 10 35 16 pm

alvinwan commented 9 years ago

I don't know if this helps, but here's heatmap.js integrated with Google Maps. http://www.crimeheatmap.ca/#

screen shot 2015-09-17 at 2 49 19 pm
davidwagner commented 9 years ago

Thanks! Note to self: if I've got too much data for heatmap.js, I should also check out webgl-heatmap.

I skipped doing this for the privacy lecture, but it could be fun to show people how to construct a heatmap in a future semester and students might find it a helpful way to visualize data. Especially if it's just a method on Table (Table.heatmap('latitude', 'longitude')). So consider this a candidate enhancement to the datascience library for some unspecified point in the future. :-)

pattyf commented 8 years ago

The latest version of folium has a heatmap plugin. I've tested it with a file of 23,000 points and it works well/fast. See attached zipfile for example. It would be great to upgrade to the newer version of folium. crime_heatmap.zip

ryanlovett commented 8 years ago

Looks like datascience has a hard dependency on folium 0.1.5. @papajohn or @SamLau95, do you know if using folium 0.2.x would break datascience?

papajohn commented 8 years ago

Probably, but we will just need to update datascience to use whatever interface changes have been published for folium since the previous version. I don't think it's a lot of work. Certainly we could get it done before August.

On Saturday, July 9, 2016, Ryan Lovett notifications@github.com wrote:

Looks like datascience has a hard dependency https://github.com/data-8/datascience/blob/master/requirements.txt#L1 on folium 0.1.5. @papajohn https://github.com/papajohn or @SamLau95 https://github.com/SamLau95, do you know if using folium 0.2.x would break datascience?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/data-8/datascience/issues/69#issuecomment-231569477, or mute the thread https://github.com/notifications/unsubscribe/AATikc0HjsimtijP-C8oohndOCTd4iUqks5qUG7jgaJpZM4F9N8l .

pattyf commented 8 years ago

FYI attached is an example notebook & html file of a heatmap of 600,000 license plate reader points. It can also create a heatmap from 3 million points but slow to create and view in browser. licplate_heatmap.zip

davidwagner commented 5 years ago

With the benefit of time, this doesn't seem like a priority to me any more.