folium

Is there a way to plot many markers in Folium?

和自甴很熟 提交于 2019-12-07 10:18:26
I am trying to use Folium for geographical information reading from a pandas dataframe. The code I have is this one: import folium from folium import plugins import pandas as pd ...operations on dataframe df... map_1 = folium.Map(location=[51.5073219, -0.1276474], zoom_start=12, tiles='Stamen Terrain') markerCluster = folium.plugins.MarkerCluster().add_to(map_1) lat=0. lon=0. for index,row in df.iterrows(): lat=row['lat] lon=row['lon'] folium.Marker([lat, lon], popup=row['name']).add_to(markerCluster) map_1 df is a dataframe with longitude, latitude and name information. Longitude and latitude

create an asymmetric colormap

被刻印的时光 ゝ 提交于 2019-12-07 06:13:44
问题 I am creating a colormap to map colors in a folium choropleth map, using code from here: from branca.colormap import linear colormap = linear.RdBu.scale( df.MyValue.min(), df.MyValue.max()) colormap As you can see, the min and max values are skewed compared to the 0, and I'd like this to be reflected in the colormap, i.e. only values < 0 should be mapped to red, while all positive values should be mapped to blue. Is there a way to have this asymmetry in the colormap? I haven't seen many

Issues with Folium Choropleth Mapping Example

半世苍凉 提交于 2019-12-06 06:23:00
I am trying to create a choropleth map using folium, following the example here: https://pypi.python.org/pypi/folium . The goal is to produce a choropleth map of US unemployment rates, but when I open my map US states are not shaded in. Any suggestions? import folium import pandas as pd state_geo = r'data/us-states.json' state_unemployment = r'data/US_Unemployment_Oct2012.csv' state_data = pd.read_csv(state_unemployment) #Let Folium determine the scale map = folium.Map(location=[48, -102], zoom_start=3) map.geo_json(geo_path=state_geo, data=state_data, columns=['State', 'Unemployment'], key_on

Choropleth map using folium and pandas

徘徊边缘 提交于 2019-12-05 18:53:41
问题 I am using folium to create a choropleth map of a set of countries. I am following the documentation. However. for some reason the map doesn't show any shades. I am using the world geojson from natural earth (see the gist). My dataframe looks like: >>> spatial_scores.head() Out[1]: id Country Score PER Peru 2.810300 HND Honduras 2.734521 GUF French Guiana 2.730886 SLV El Salvador 2.473134 CRI Costa Rica 2.454963 The world geojson looks like: >>> world_json['features'][0]['id'] Out [2]: u'AFG'

Folium maps not showing up on jupyter notebook uploaded on github

我的梦境 提交于 2019-12-05 08:09:39
I have successfully rendered folium maps on my jupyter notebook by increasing the data limit when launching jupyter from anaconda prompt like this: "jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10" However, when I have uploaded the notebook to Github, rather than the map I had processed, I got a blank window. How can I render these maps? Is it possible to increase the data_rate_limit on the notebook when it is being launched through github? 来源: https://stackoverflow.com/questions/46431442/folium-maps-not-showing-up-on-jupyter-notebook-uploaded-on-github

Create a Legend on a Folium map

╄→尐↘猪︶ㄣ 提交于 2019-12-05 01:29:04
The Folium documentation is incomplete at this time: https://folium.readthedocs.io/en/latest/ According to the index of the incomplete docs Legends and Layers are, or will be supported. I've spent some time looking for examples on the web but have found nothing so far. If anyone has any idea how to create these things, or can point me to a document or tutorial I would be most grateful. You can add a legend quite easily; #specify the min and max values of your data colormap = branca.colormap.linear.YlOrRd_09.scale(0, 8500) colormap = colormap.to_step(index=[0, 1000, 3000, 5000, 8500]) colormap

Python - Folium Choropleth Map - colors incorrect

与世无争的帅哥 提交于 2019-12-04 21:26:10
My problem is that suburbs are not displaying the correct color on the Folium map. For example, Dandenong and Frankston should be shaded with the darkest color as they have the highest count in the dataframe, but they are shaded with a lighter color. The dataframe is missing some suburbs. Those suburbs are being colored with the darkest color. Another problem is the csv has all suburbs in UPPERCASE but the geojson has a mixture of cases such as "Frankston", "St Kilda", or "McKinnon". It would be helpful if the choropleth code didn't care about case. I can change the text in the dataframe to

Choropleth map using folium and pandas

两盒软妹~` 提交于 2019-12-04 02:37:12
I am using folium to create a choropleth map of a set of countries. I am following the documentation . However. for some reason the map doesn't show any shades. I am using the world geojson from natural earth (see the gist ). My dataframe looks like: >>> spatial_scores.head() Out[1]: id Country Score PER Peru 2.810300 HND Honduras 2.734521 GUF French Guiana 2.730886 SLV El Salvador 2.473134 CRI Costa Rica 2.454963 The world geojson looks like: >>> world_json['features'][0]['id'] Out [2]: u'AFG' The relevant portions of the choropleth codes are as below: map1 = folium.Map(location=[-15., -60],

Plot colored polygons with geodataframe in folium

天涯浪子 提交于 2019-12-03 10:20:01
问题 I'm trying to plot radar data in folium, and I'm almost there. I followed this example (Contour plot data (lat,lon,value) within boundaries and export GeoJSON) to get my data into a GeoJson format. nb_class = 20 collec_poly = plt.contourf(lons,lats,np.array(poshdata), nb_class,alpha=0.5) gdf = collec_to_gdf(collec_poly) # From link above gdf.to_json() colors = [p.get_facecolor().tolist()[0] for p in collec_poly.collections] gdf['RGBA'] = colors gdf This outputs two columns: geometry and RGBA.

Insert the folium maps into the jinja template

风流意气都作罢 提交于 2019-12-03 09:47:41
问题 I want to insert follium map into the jinja template. run.py from flask import Flask, render_template app = Flask(__name__) @app.route('/') def index(): start_coords = (46.9540700, 142.7360300) folium_map = folium.Map(location=start_coords, zoom_start=14) folium_map.save() return render_template('index.html', folium_map=folium_map) if __name__ == '__main__': app.run(debug=True) template/index.html - jinja template for Flask {% extends "layout.html" %} {% block title %}Test{% endblock %} {%