Please see Optimizing a double loop for inspiration - it discusses a slighly different problem, but similar techniques could be used for solving your problem.
It might help if you included a sample of real data, which would make it easier for us to get a feel for the characteristics of the data.
Perl 6 - links to (nearly) everything that is Perl 6.
Comment on Re: mapping coordinates- suggestion needed