Example #1
0
#         if sp == 'O3':
#             plt.annotate("mean: " + str(airpact[sp].mean(axis=0).mean()) +" ppb", xy=(0, 1.02), xycoords='axes fraction')
#         else:
#             plt.annotate("mean: " + str(airpact[sp].mean(axis=0).mean()) +" $ug/m^3$", xy=(0, 1.02), xycoords='axes fraction')
#         
#         pdf.savefig(fig) 
#         plt.show()
# =============================================================================
      

#%%
######################################
        # Plot folium
######################################
m= folium.Map(location=[47.6588, -117.4260],zoom_start=9) # Create the plot
m.add_child(folium.LatLngPopup()) #Add click lat/lon functionality

# mins and max's of the plot
lon_min=np.amin(urbanova['lon'])
lat_min=np.amin(urbanova['lat'])
lon_max=np.amax(urbanova['lon'])
lat_max=np.amax(urbanova['lat'])

extents = [[lat_min, lon_min], [lat_max, lon_max]]

# Add monthly average maps to Folium
for sp in var_list:
    folium.raster_layers.ImageOverlay(base_dir +'maps/cctm_comp/delta_basemap_' +str(end_month)+'_'+ sp + '.png',bounds = extents,name=sp,opacity = 0.5, show = False).add_to(m)
    folium.raster_layers.VideoOverlay(video_url=git_dir+'movie_'+sp+'_output.webm',bounds = extents,name=sp+'video',opacity = 0.5,attr = sp+'video',show = False,autoplay=True).add_to(m)

Example #2
0
    'weight': 0.1
}

toolkit = folium.features.GeoJson(
    state_map,
    style_function=style_function,
    control=False,
    highlight_function=highlight_function,
    tooltip=folium.features.GeoJsonTooltip(
        fields=['State', 'Count'],
        aliases=['State: ', '# of Accidents: '],
        style=
        ("background-color: white; color: #333333; font-family: arial; font-size: 12px; padding: 10px;"
         )))

m.add_child(toolkit)
m.keep_in_front(toolkit)
folium.LayerControl().add_to(m)

m

# Hover over each state will pop a toolkit that show the state name and the count of accidents. Most of the accidents in this dataset are in **California**, followed by **Texas** and **Florida**.
#
# Then we want to focus on the State of California to see which area of the state have the most accidents. using the similar code that produced US State Choropleth map. the following code produced Calfornia State zip code Choropleth map.

# In[65]:

shapefile_zip = '/Users/leo/Personal/Python/cb_2018_us_zcta510_500k/cb_2018_us_zcta510_500k.shp'

#Read shapefile using Geopandas
gdf_zip = gpd.read_file(shapefile_zip)