If the polygon layout data table is regular and complete
Names Default To Here( 1 );
// Create the example data tables
New Table( "Data",
Add Rows( 4 ),
New Column( "x", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0.5, 1.5, 0.5, 1.5] ) ),
New Column( "y", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0.5, 0.5, 1.5, 1.5] ) )
);
New Table( "Layout",
Add Rows( 9 ),
New Column( "X", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1, 2, 0, 1, 2, 0, 1, 2] ) ),
New Column( "Y", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 0, 0, 1, 1, 1, 2, 2, 2] ) ),
New Column( "V", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [0, 1, 2, 1, 2, 3, 2, 3, 4] ) ),
Set Row States( [8, 8, 8, 8, 8, 8, 8, 8, 8] ),
Set Label Columns( :V )
);
// Calculate the IV data
dtLookup = Data Table( "Layout" );
dtData = Data Table( "Data" );
dtData << New Column( "IV" );
For( i = 1, i <= N Rows( dtData ), i++,
xVal = dtData:X[i];
yVal = dtData:Y[i];
yMin = Col Max( If( dtLookup:Y < yVal, dtLookup:Y, . ) );
yMax = Col Min( If( dtLookup:Y > yVal, dtLookup:Y, . ) );
xMin = Col Max( If( dtLookup:X < xVal, dtLookup:X, . ) );
xMax = Col Min( If( dtLookup:X > xVal, dtLookup:X, . ) );
botLeft = dtLookup:V[(dtLookup << get rows where( :X == xMin & :Y == yMin ))[1]];
botRight = dtLookup:V[(dtLookup << get rows where( :X == xMax & :Y == yMin ))[1]];
topLeft = dtLookup:V[(dtLookup << get rows where( :X == xMin & :Y == yMax ))[1]];
topRight = dtLookup:V[(dtLookup << get rows where( :X == xMax & :Y == yMax ))[1]];
dtData:IV[i] = Mean( botLeft, botRight, topLeft, topRight );
);
Jim