The apparatus and method of the invention provide for assigning coordinates to samples in an array. The method is based on a hierarchical pattern matching to a local lattice structure that is used as a template. Starting from the best local match, the pattern is expanded hierarchically to encompass the entire array.