Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- com_dist = mongo.mongo_to_dateframe(['district', 'district_name', 'population'])
- com_dist.columns = ['ID_DISTICT', 'NAME_DISTICT', 'population']
- nill = geopandas.read_file('community_dist.json')
- nill = geopandas.read_file('community_dist.json')
- nill = nill[['BoroCD','geometry', 'Shape__Area']]
- nill.columns = ['ID_DISTICT','geometry', 'area']
- nilpop = nill.merge(com_dist,on="ID_DISTICT")
- mymap = folium.Map(location=[40.75, -74.125], zoom_start=10.5,tiles=None)
- folium.TileLayer('CartoDB positron',name="Light Map",control=False).add_to(mymap)
- style_function = lambda x: {'fillColor': '#ffffff',
- 'color':'#000000',
- 'fillOpacity': 0.1,
- 'weight': 0.1}
- highlight_function = lambda x: {'fillColor': '#000000',
- 'color':'#000000',
- 'fillOpacity': 0.50,
- 'weight': 0.1}
- mymap.choropleth(
- geo_data=nilpop,
- name='Choropleth',
- data=nilpop,
- columns=['ID_DISTICT','PER_FOREIGN'],
- key_on="feature.properties.ID_DISTICT",
- fill_color='YlGnBu',
- threshold_scale=myscale,
- fill_opacity=1,
- line_opacity=0.2,
- legend_name='Resident foreign population in %',
- smooth_factor=0
- )
- NIL = folium.features.GeoJson(
- nilpop,
- style_function=style_function,
- control=False,
- highlight_function=highlight_function,
- tooltip=folium.features.GeoJsonTooltip(
- fields=['ID_DISTICT', 'NAME_DISTICT', 'population', 'area'],
- aliases=['District Code: ', 'District Name: ','Dictrict population: ', 'Shape Area:'],
- style=("background-color: white; color: #333333; font-family: arial; font-size: 13px; padding: 10px;")
- )
- )
- mymap.add_child(NIL)
- mymap.keep_in_front(NIL)
- folium.LayerControl().add_to(mymap)
- mymap.save(outfile='map-test.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement