0

I have a df of incident report information with a few columns. Among them, I have the column of year (year of the report information), latitude and longitude. This df has around 1.1 million lines as below

YEAR    LAT            LONG
2007    -23.54888115   -46.61859308
2007    -23.53578729   -46.76441089
2011    -23.60330318   -46.67685451
2018    -23.5403854    -46.3614019

I want to make a heat graph per year using the lat and long information but I have no idea how to iterate over the years and for each year plot the latitudes and longitudes.

map = folium.Map(location=[-23.5475, -46.63611])
ano = df_furtos['ANO_BO'].tolist()
lat = df_furtos['LATITUDE'].tolist()
lng = df_furtos['LONGITUDE'].tolist()
HeatMap(list(zip(lat, lng))).add_to(map)

I'm using Folium to plot the graph, but I know how to make the graph just by using lat and long.

However, I want that if I have a 10-year history of lat and long, I want to plot 10 graphs each with their respective latitudes and longitudes.

Can someone help me? Thanks!!

  • You should use `groupby()` to group your data by years. – DYZ Feb 15 '20 at 22:38
  • May I know what is a heat graph? You mean the LAT and LONG are unique and can repeat themselves many times a year? – SKPS Feb 15 '20 at 22:38
  • a heat graph would be a graph where the places where there are more "occurrences" are with stronger color tones, like red for example. In my case, lat and long are not unique, as they refer to car thefts – Danilo Perl Feb 15 '20 at 22:45
  • In that case, you would need some form of interpolation scheme since the lat, longs are unique. Isnt it? – SKPS Feb 15 '20 at 22:46
  • lat and longs are unique but can be repeated. But I have my entire data set ready – Danilo Perl Feb 15 '20 at 22:48
  • Sorry that was stupid. Heatmap would have resolution and count unique values in that region. Isn't it? – SKPS Feb 15 '20 at 22:48
  • That! I have these values. but I need to iterate over the list containing the year and values ​​and for each year plot the graph – Danilo Perl Feb 15 '20 at 22:49
  • I wonder you could only create a scatter plot but not heat map for this 2D data (lat, long). Heat map is possible only if there is third dimension. Isn't it? For example: https://stackoverflow.com/questions/38264887/heat-map-of-spatial-data-in-python – SKPS Feb 16 '20 at 01:33

0 Answers0