cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

Matching Spatially Inhomogeneous Data

I have two data tables of values that are spatially mapped, but the coordinates of one table are not the same coordinates as the second. I would like to "Join" these tables but have the data match by coordinate so I can compare the spatially variant values between the two tables.

 

Does anyone know if there's an easy way to do this instead of just brute force calculating for every value? There looks to be some interesting matrix functions but I am unfamiliar with the mathematical concepts behind them.

 

I  have a mockup of the process shown below that hopefully conveys what I want to have happen.

View more...
XYV
000
101
202
011
112
223
022
123
224

 + 

XY
0.50.5
1.50.5
0.51.5
1.51.5

=> 

XYI V
0.50.51
1.50.52
0.51.52
1.51.53
 
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Matching Spatially Inhomogeneous Data

5 REPLIES 5
jthi
Super User

Re: Matching Spatially Inhomogeneous Data

I think VPTree() or Distance() could work here (maybe KDTable()), but what do you do in ties?

Not looking for closest points but rather points in same line and interpolation after that if I understood correct.y.

-Jarmo
txnelson
Super User

Re: Matching Spatially Inhomogeneous Data

I do not understand how you come up with the value for IV.  Could you please explain the rules you are using? 

Jim

Re: Matching Spatially Inhomogeneous Data

IV was the interpolated value of XYV (Table 1) from the table, using the coordinates from the XY (Table 2) table

jthi
Super User

Re: Matching Spatially Inhomogeneous Data

txnelson
Super User

Re: Matching Spatially Inhomogeneous Data

If the polygon layout data table is regular and complete

txnelson_0-1655399523283.png

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