I have an interesting problem. I have been asked to create a set of polygons using dates. Below is an example table showing the data. As you can see the table is sorted by start year.
What I have to do is generate a set of polygons each time the start year, month and day changes. So the first polygon will just contain the first row of data. The second polygon will contain both the first and second and so on.
There is also another element to this. Each row of data has an end year, month and day. If a row has an end year of 2300 then that row will stay in the output once it has been added. If there is an end year that does not equal 2300 then that row will not be included in future versions of the output.
So is there anyone who can help? I have about two hundred tables like the one above. Would like a model builder solution.
Thanks in anticipation.
Paul
Solved! Go to Solution.
Hi Paul,
I'm glad it worked. Be aware that it creates the output in the same folder as the input. A second run would try to perform the same action on both the input and output files from the previous run. It might be better to create a separate workspace (folder) for the outputs. Like this:
def main():
# specify the workspace
ws = r"C:\Users\PaulBritten\Desktop\tenure\All reserves"
ws_out = r"C:\Users\PaulBritten\Desktop\tenure\YourOutputFolder" # should exist
arcpy.env.workspace = ws
arcpy.env.overwriteOutput = True
lst_fc = arcpy.ListFeatureClasses()
for fc in lst_fc:
name, ext = os.path.splitext(fc)
fc_out = "{0}_merged{1}".format(name, ext)
MergePolygonsOnDate(os.path.join(ws, fc), os.path.join(ws_out, fc_out))
Hi Xander,
Thanks for that.
Again, thanks for your assistance with this. It has been invaluable.
Paul