There are at least a few ways to do it. A. 1. Open the fine-scale surface (which I'll call S1). Open the Surface > Transform dialog and enter the following formula. SumValue([S1], 2) Set Scope to All pixels, check the option at the bottom to Save result as new component, and run the transform. This creates a new surface, the same size as S1, where each pixel gets the sum of all values in the surrounding 5x5 window (expressed here as a window size of 2--think square radius). 2. Now open the resulting new surface, S2. Open the Surface > Resize dialog. Enter Nearest Neighbour for the Method, and divide the current width and height by 5. (I'm hoping that the original dimensions are both exact multiples of 5. Otherwise it may be necessary to ensure this by adding extra edge pixels.) This shrinks the surface S2 to the size of the coarse dataset. Using nearest neighbour means sampling just the centre pixel in each 5x5 window, discarding the rest; from step 1, this centre pixel contains the sum of all the values in this window. That's probably the simplest way, and as fast as you'll get in Manifold. (If you have a CUDA-capable graphics card, then step 1 uses GPGPU for greater speed.) B. The same can be done via SQL. 1. First make a duplicate S2 of the fine-scale surface S1 or, since this is quicker, make a new surface S2 having the same dimensions and data type as S1, then use Assign Projection to give it the exact projection of S1. (Uncheck "Preserve local values, then use the Load from component button, upper right.) 2. Create and run the following query. UPDATE [S2] SET [Height (I)] = HeightSum([S1], [X (I)], [Y (I)], 2); Now resize as for step 2 in A. C. Again via SQL, but using a coarse-scale surface as the target. 1. Create a duplicate S4 of the coarse scale surface S3, or the alternative as in B step 1 above, for the different surfaces. 2. Create and run the following query. UPDATE [S4] SET [Height (I)] = HeightSum( [S1], BoundingBox(AssignCoordSys( NewLine( NewPoint([X (I)], [Y (I)]), NewPoint([X (I)] + 1, [Y (I)] + 1) ), CoordSys("S4" AS COMPONENT) )) ); (No need to resize after this method.) I expect method A will be fastest and C will be slowest.
|