Solved! Go to Solution.
#set the mosaic dataset ws_mosaic = r'C:\MyFolder\MyGDB.gdb\MosaicDS' # add the date field arcpy.AddField_management (ws_mosaic, "_calcDate", "DATE") print "Date field added" # calcuate the date field ras = str(ws_mosaic) fld = "_calcDate" cursor = arcpy.UpdateCursor(ras, '', '', '', 'Name') # in this case, the actual date to start from was not important startDate = datetime.datetime(1901,1,1) step = datetime.timedelta(days=1) d = startDate # now populate the date field for row in cursor: retVal = datetime.datetime.strptime(str(d), '%Y-%m-%d %H:%M:%S') row.setValue(fld, retVal) cursor.updateRow(row) d += step
#set the mosaic dataset ws_mosaic = r'C:\MyFolder\MyGDB.gdb\MosaicDS' # add the date field arcpy.AddField_management (ws_mosaic, "_calcDate", "DATE") print "Date field added" # calcuate the date field ras = str(ws_mosaic) fld = "_calcDate" cursor = arcpy.UpdateCursor(ras, '', '', '', 'Name') # in this case, the actual date to start from was not important startDate = datetime.datetime(1901,1,1) step = datetime.timedelta(days=1) d = startDate # now populate the date field for row in cursor: retVal = datetime.datetime.strptime(str(d), '%Y-%m-%d %H:%M:%S') row.setValue(fld, retVal) cursor.updateRow(row) d += step
##Create Raster Mosaic Dataset to contain Surfaces. print "Creating Surfaces Raster Dataset." FeatureDatasetName = "Surfaces" arcpy.CreateMosaicDataset_management(OutDatasetPath,FeatureDatasetName,Spatial_Reference) ##Add an 8 character Text field to hold Date as YYYYMMDD. RasterDatasetLocation = os.path.join(OutFolderPath,GeoDatabaseName,"Surfaces") arcpy.AddField_management(RasterDatasetLocation, "SurfaceDate","Text","","",8) DateStart = date(2013,7,1) DateEnd = date(2013,7,31) for dt in rrule(DAILY, dtstart=DateStart, until=DateEnd): ##Do lots of processing in this loop. ##Populate Raster Mosaic Table with Dates. arcpy.env.workspace = os.path.join(OutFolderPath,GeoDatabaseName,"Surfaces") ras = str(os.path.join(OutFolderPath,GeoDatabaseName,"Surfaces")) flds = ["Name","SurfaceDate"] cursor = arcpy.da.UpdateCursor(ras,flds) for row in cursor: RasterName = row[0] DateString = RasterName[-8:] row[1] = DateString cursor.updateRow(row) print "Contours Completed."