A clustering algorithm for spatially dependent functional data