GeoTools : Guide to standalone usage of interpolations

Interpolations algorithms can be also used as standalone functions. Here is the example:

```// TODO: Need package names here so we can find them, at least for TPS...

...

// We use a single Coordinate Reference System
CoordinateReferenceSystem crs = DefaultEngineeringCRS.CARTESIAN_2D;

// Define the Envelope for our work; this will be the bounds of the final interpolation
GeneralDirectPosition min = new GeneralDirectPosition( new DirectPosition2D(crs,   0.0,   0.0) );
GeneralDirectPosition max = new GeneralDirectPosition( new DirectPosition2D(crs, 100.0, 100.0) );
Envelope env = new GeneralEnvelope(min,max);

// Generate some known points to root the interpolation
DirectPosition a = new DirectPosition2D(crs,13,85);
DirectPosition b = new DirectPosition2D(crs,14,15);
DirectPosition c = new DirectPosition2D(crs,45,78);
DirectPosition d = new DirectPosition2D(crs,95,28);

// Define at each point the values to be interpolated; we do this in a HashMap
HashMap /*<DirectPosition2D, Float>*/ pointsAndValues = new HashMap();
pointsAndValues.put(a,  6.5);
pointsAndValues.put(b,  1.5);
pointsAndValues.put(c, -9.5);
pointsAndValues.put(d,  7.5);

//now we can construct the Interpolation Object
TPSInterpolation interp = new TPSInterpolation(pointsAndValues, 1, 1, env);

// We can create and show a coverage image of the interpolation within the Envelope
GridCoverageFactory gcf = new GridCoverageFactory();
gcf.create("Intepolated Coverage",  interp.get2DGrid(), env).show();

// We can also generate an interpolated value at any DirectPosition
float myValue = interp.getValue(new DirectPosition2D(crs,12.34,15.123));

```

And you should see something like this:

Attachments:

p.png (image/png)