I am having some trouble creating a new shapefile and CSV to group wildfires into seasons.
What I want to do is to group the wildfires by meteorological season (summer, fall, winter and spring) for each year. Then, I would like to know how many wildfires and the area burned in each season for each year from 1950 to 2017.
Summer starts from 1st of June to 31st August, fall from 1st September to 30th November, winter from 1st December to 28/29 February and spring from 1st March to 31 May.
The result might be similar to this by creating a new field called "Season", another one called "Count" (to see how many wildfires are in that season) and another column called Season_acres which will be the sum of all acres burned in a season.
So far I have got these two separate scripts:
- Using an update cursor
fc = "fires_1950-2017.shp"
newfield = "MET_SEAS"
fieldtype = "TEXT"
fieldname = arcpy.ValidateFieldName(newfield)
print "cleaned up fieldname:", fieldname
arcpy.AddField_management(fc, fieldname, fieldtype, "", "",12)
print "New field created!"
delimfield = arcpy.AddFieldDelimiters (fc, "ALARM_DATE")
cursor = arcpy.da.UpdateCursor(fc, ["MET_SEAS"], """ALARM_DATE >= date '1950-06-01 00:00:00' AND ALARM_DATE <= date '1950-08-31 00:00:00'""")
for row in cursor:
row[0] = "Summer 1950"
cursor.updateRow(row)
del cursor
- Using Statistics analysis, which I am not able to use with an update cursor
in_table = "fires_1950-2017.shp"
out_table = r"D:\edited_data\try.csv"
stat_fields = [["GIS_ACRES", "SUM"], ["GIS_ACRES", "MEAN"]]
stats = arcpy.Statistics_analysis(in_table, out_table, stat_fields)
print "script finished"