I am trying to plot a large number (~20,000) of circle markers using Folium. The latitude and longitude data is contained in a Pandas DataFrame (within "LAT" and "LONG" columns). I have come up with the following (inefficient) code, which requires iterating through the dataframe row by row. Not surprisingly, it takes quite a while to plot the map. Is there a better/faster way to accomplish this?
Meanwhile, I do not have to use Folium. If there is a more suitable tool that you know of (I still have to keep the data in a Pandas DataFrame though), please let me know.
Thanks!
map_osm = folium.Map(location=[43.094768, -75.348634])
for index, row in df.iterrows():
folium.CircleMarker(location=[row["LAT"], row["LONG"]]).add_to(map_osm)
map_osm
Let's create a Pandas dataframe. It provides a numeric value for a few big cities, along with their geographic coordinates Now, loop through this dataframe, and add a marker to each location thanks to the Marker () function: # add marker one by one on the map for i in range(0,len( data)): folium.
It provides a numeric value for a few big cities, along with their geographic coordinates Now, loop through this dataframe, and add a marker to each location thanks to the Marker () function: # add marker one by one on the map for i in range(0,len( data)): folium.
2. Plotting With GeoPandas 3. Choropleth Maps 4. Scatter Plots on Maps Geopandas provides easy to use interface which lets us work with geospatial data and visualize it. It lets us create high-quality static map plots.
Say you have geographic data you want to plot; you could use a bar graph with country names and plot your data as a bar, but that’s boring. A more visually appealing way of presenting the data would be to overlay it on a map to physically show how your data interacts. This can be a challenging endeavor, but I’m here to help.
Use apply along the column axis:
df.apply(lambda row:folium.CircleMarker(location=[row["LAT"],
row["LONG"]]).add_to(map_osm),
axis=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With