Home > Software engineering >  Can't get rid of these circles while making a folium driven heat map
Can't get rid of these circles while making a folium driven heat map

Time:11-07

I'm making a heat map with folium and some open crime data from the city of Portland. When I make the final heatmap, it looks fine, except these blue circles cover up all the heat map colors, making it look like a bunch of blue blobs. enter image description here

Like the blue dots I get, but the circles around them obliterate the actual colorful qualities of the heat map. How do I hide these blue circles? I'm following the example here where there's no weird blue circles. Here's my code:

import folium
from folium import plugins
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

%matplotlib inline

crime = pd.read_csv("../Data/CleanedCrimeData-2021.csv")
crime['OccurTime'] = crime['OccurTime'].apply(str)
crime['OccurTime'] = crime['OccurTime'].apply(lambda x: x.zfill(4))
crime['CrimeDate'] = crime.OccurDate   ' '   crime.OccurTime
crime['CrimeDate'] = pd.to_datetime(crime['CrimeDate'])
cols = list(crime)
crime = crime.loc[:, cols]
crime.set_index('CrimeDate', inplace=True)

m = folium.Map(location=[45.5291, -122.6768], zoom_start=12)
for index, row in crime.iterrows():
    folium.CircleMarker([row['OpenDataLat'], row['OpenDataLon']],
                        radius=1,
                        popup=row['OffenseType'],
                        fill_color="#3db7e4", # divvy color
                       ).add_to(m)
# convert to (n, 2) nd-array format for heatmap
crimeArr = crime[['OpenDataLat', 'OpenDataLon']]

# plot heatmap
m.add_child(plugins.HeatMap(crimeArr))
m

CodePudding user response:

Use the radius keyword of the Heatmap to adjust the radius of the circles.

This could look like this:

plugins.HeatMap(crimeArr, radius=0)
  • Related