#!/usr/bin/env python # coding: utf-8 # In[1]: import folium import geopandas as gpd import rasterio from rasterio.mask import mask import pandas as pd # In[2]: counties = gpd.read_file(r'C:\Users\kperham\Projects\dashboard\fl_counties\fl_counties.geojson') # In[3]: # NIFC Wildfire Perimeters - Active fires = gpd.read_file(r'https://opendata.arcgis.com/datasets/5da472c6d27b4b67970acc7b5044c862_0.geojson') # In[4]: # Get the FL county and format the fire names fires_fl = gpd.sjoin(fires, counties, how="inner", op='intersects') fires_fl.IncidentName=fires_fl.IncidentName.str.title() # In[5]: fires_fl.reset_index(inplace=True) # In[6]: fires.to_file(r'C:\Users\i23733\OneDrive - Verisk Analytics\__Projects\dashboard\fires.gpkg', driver="GPKG") # from datetime import date, datetime, timedelta # # today = date.today() # def dateNIFC(datefield): # global dt_string # dt_string = today.strftime("%Y-%m-%d %H:%M:%S") # return dt_string # d = datetime.today() - timedelta(days=5) # print(dateNIFC(fires_fl['Date'])),(d) # In[7]: fires_fl['Date'] = pd.to_datetime(fires_fl['DateCurrent']).astype(str) fires_fl['CreateDate'] # In[8]: state_acres = fires_fl.groupby(['state'])['GISAcres'].sum().reset_index().sort_values("GISAcres", ascending=False) incident_acres = fires_fl.groupby(['IncidentName','state'])['GISAcres'].sum().reset_index().sort_values("GISAcres", ascending=False) recent_fires = fires_fl.loc[fires_fl.GISAcres > 50][['IncidentName','state','GISAcres','Date']].sort_values('Date', ascending=False) #recent_acres_burned = fires_fl.loc[[fires_fl.Date > (d)]] print(incident_acres[0:5]),(state_acres[0:5]),(recent_fires[0:10]) # In[18]: tile = "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}" attribu = 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' m = folium.Map([42,-110], zoom_start=5, tiles=tile,attr=attribu) # In[19]: fires_fl['reported_acres'] = round(fires_fl['GISAcres'],0) folium.GeoJson(fires_fl, tooltip=folium.features.GeoJsonTooltip( fields=['IncidentName','reported_acres','state','Date'], aliases=['Fire Name:','Reported Acres','State','Last Updated']) ).add_to(m) # In[20]: m # In[11]: fires_fl.head()