# Closest set of points to another set of (predefined) points

I have 10 sets of points which I call templates that I have manually classified from 0 to 10. Each point is a X, Y coordinate in a text file. Each template has 5-8 points. I have new sets of points that I want to classify as one of the templates. The points are scale and rotation invariant. Each set of points may not have the same number of points with the template that it corresponds to. there's also differences in the X,Y coordinates (meaning they're not identical) but they are similar.
So I think what I need is the closest set of points (from the templates) to another set of points (the one I have as input).

I can generate polygons from each set of points so the question can become: how can I match the closest polygon to a set of points.

Maybe generate some signature and grade the set of points against each of the templates?

Please note that I'm not familiar with GIS. I'm wondering if GIS can help me with this kind of problem.

-
What software do you have to work with? ArcGIS, QGIS, Manifold, online, etc.? – Baltok Jan 8 '13 at 14:33
or do you want to use R? – A.R Jan 8 '13 at 14:45
Ideally some kind of programmable library/API. I'm mostly using C# and Perl. FOSS if possible. – John Kornick Jan 8 '13 at 14:46
If your input is relatively small (a million points or less, approximately) it will suffice to compute all distances between those points and the "template" points and choose the closest ones. We're talking about less than 10^8 distance calculations which, on a modern core in a compiled language, would take less than a second (and it's a very easy procedure to code). If you have larger inputs, please provide more details of the situation, including what these "templates" really mean, the purpose of your exercise, and how many points you actually have. – whuber Jan 8 '13 at 16:50
The input points are just 5 to 8, so very small. But are you suggesting comparing all the vector combinations? – John Kornick Jan 8 '13 at 17:11