This is the first real world python program am trying to write. I am trying to create a scrip that takes a shapefile that has n polygons with an integer formatted date (e.g. yyyymmdd or 6/24/2014 is 20140624) attribute and returns a shapefile which has a single polygon for each date, and that polygon is the summation of all polygons with that date or earlier. Additionally I need the polygon to retain the the attributes of the most recent polygon.
My initial thought was to manually sort the attribute table form most recent to oldest and have something like this to do the rest:
import arcpy
form arcpy import env
import shapefile
w = shapefile.Writer()
# Create a list of all off the features in the shapefile.
def generate_working_list(a):
env.workspace = "a"
wl = arcpy.ListFeatureClasses()
# copy the oldest polygon, merge it with the next oldest, copy the newly created polygon, repeat
def aggregate(wl):
twl = []
fl = []
wl[-1].append(twl)
wl[-1].append(fl)
wl.pop()
while len(wl) > 1:
wl[-1].append(twl)
'''Dissolve/ merge twl'''
twl[0].append(fl)
wl.pop()
swl[0].append(twl)
arcpy.Append_management(twl, fl) '''I think that this is the right tool to use'''
twl[0].append(fl)
return fl
w.save("Merged")