Table of Contents 1.Introduction 3 2.Elementary Grid Shift File Description 4 Subroutine GRIDINT 18 Appendix B: Version 2 Grid_Shift_File 25 1.Introduction This document provides complete specifications for the hybrid grid shift file structure used in Version 2 of the National Transformation, and the procedures used to access and apply the data it contains. This documentation is intended for third-party developers who are licensed to incorporate the NTv2 as a feature of their products, or for end users who integrate the NTv2 into their own systems or perform other custom modifications for in-house use. A descriptive overview of the file structures and how they are used is given in Sections 2, 3, 4, and 5. Section 2 describes the elementary grid shift file. Section 4 gives a description of the three essential processes to access the grid shift files, and Section 5 suggests various strategies for implementation into the developer's environment. Detailed descriptions of the three processes are given next. Finally, Appendice B contain detailed specifications of the record structures for Version 2. 2.Elementary Grid Shift File Description The National Transformation Version 2 was based on a grid shift file that is strictly regular in structure. It must cover a rectangular area bounded by unique values for each of the following: lower latitude, upper latitude, lower longitude, and upper longitude. The grid intervals are specified separately for latitude and longitude, and are fixed at these values throughout the file. Indexing of grid intersection points begins at the lower right-hand, or south- east, corner of the grid rectangle (Figure 1). Figure 1: Grid Limits and Point Indexing ----------------------------------------- Longitude Interval dLon #-------# Upper +-------+-------+-------+-------+ -- Latitude m*n| | | | | Limit | | | | | N | | | | | +-------+-------+-------+-------+ | | | | | | | | | | | | | | | +-------+-------+-------+-------+ # 3n| ...| 2n+3| 2n+2| 2n+1| | Latitude | | | | | | Interval | | | | | | dLat +-------+-------+-------+-------+ # 2n| ...| n+3| n+2| n+1| | | | | | | | | | | Lower +-------+-------+-------+-------+ -- Latitude n ... 3 2 1 Limit S | | Upper Lower Longitude Longitude Limit Limit W E n = number of columns m = number of rows W - E N - S n = integer( ----- ) + 1 m = integer( ----- ) + 1 dLon dLat This type of structure allows the direct computation of the record indices for the four corners of the cell containing a point to be processed (Figure 2). Since no search algorithms are required, speed of retrieval is independent of file size. It also permits the reduction of file size by creating a subset covering a smaller rectangular area within the original, suiting users with a more regional interest. Figure 2: Grid Cell Direct Indexing ------------------------------------ jth column | +-------+-------+-------+-------+ | | | | | | | | | | | | | | | +-------o-------o-------+-------+ | D| C| | | | | o | | | | | P | | | +-------o-------o-------+-------+ -- ith row | B| A| | | | | | | | | | | | | +-------+-------+-------+-------+ | | | | | | | | | | | | | | | +-------+-------+-------+-------+ Lat(P) - S i = integer( ---------- ) + 1 A = n(i-1) + j dLat B = A + 1 Lon(P) - E C = A + n j = integer( ---------- ) + 1 dLon D = C + 1 The size of the file, as determined by the area it covers and the density of the grid, does not affect the software used to access and apply the data. All of the information required to describe the data is contained in a block of header records at the beginning of the file. The header records are followed by the grid shift records which contain the predicted shifts at each point in the grid. The last record is a flag to indicate the end of file. This elementary grid shift file is also used as the fundamental building block for Version 2. The major difference is that while the Version 1 grid shift records have two double precision variables for the latitude and longitude shifts, the Version 2 grid shift records contain four single precision values for the two shifts and their estimated accuracies. Subroutine GRIDINT Grid_Shift_Interpolation 1.Retrieve Grid Shifts If a specific grid point is to be retrieved, then the Record_Index of that point is computed by the following sequence (see Figures 1 & 2 in Section 2: Elementary Grid Shift File Description): Point_Latitude - Lower_Latitude Row_Index = --------------------------------- + 1 Latitude_Grid_Interval Point_Longitude - Lower_Longitude Column_Index = ----------------------------------- + 1 Longitude_Grid_Interval Upper_Longitude - Lower_Longitude Grid_Points_Per_Row = ----------------------------------- + 1 Longitude_Grid_Interval Record_Index = ( Row_Index - 1 ) * Grid_Points_Per_Row + Column_Index + Sub_File_Offset All division operations are truncated to integers. Thus, if the point coordinates are not exactly identical to coordinates of a grid point, the Record_Index will correspond to the lower right-hand corner of the grid cell which contains the point. This means that if a point is on the lower limit of the cell, it is considered as in the cell, but if it is on the upper limit, it is considered as being in the next adjoining cell. If the four grid points of the corners of the cell are to be retrieved, then the same sequence as above is used to first determine the Record_Index_LR. The Record_Indexes for each of the other three corners are determined as: Record_Index_LL = Record_Index_LR + 1 Record_Index_UR = Record_Index_LR + Grid_Points_Per_Row Record_Index_UL = Record_Index_UR + 1 If the coordinates of the point are exactly on either of the upper limits of latitude or longitude, as indicated by the limit flag returned by subroutine FGRID, then the cell is actually outside the area covered by the Grid_Shift_Sub_File. To address this situation, the grid is virtually extended by one cell beyond the upper limit. Grid shift values are assigned to the corners of the cell, according to the limit flag, as follows: [1] point is within the limits - shift values for all four corners of the cell are used, no virtual cell is required [2] point is on the upper latitude limit - shift values for the two available cell corners are used for both the lower and upper latitude corners of the virtual cell [3] point is on the upper longitude limit - shift values for the two available cell corners are used for both the lower and upper longitude corners of the virtual cell [4] point is on both upper latitude and upper longitude limits - shift values for the single available cell corner are used for all four corners of the virtual cell Case 1: (point is within limits) ~~~~~~ d c d c +------+ +------+ | | | | | P o | no change | P o | | | | | +------+ +------+ b a b a Case 2: (point is on upper latitude limit) ~~~~~~ b a +......+ P : : +---o--+ becomes : : b a : P : +---o--+ b a Case 3: (point is on upper longitude limit) ~~~~~~ c c c + +......+ | : | P o becomes : P o | : | + +......+ a a a Case 4: (point is on both upper latitude and longitude limits) ~~~~~~ a a +......+ P : : o becomes : : a : P : +......o a a 2.Interpolate Grid Shifts The grid_shifts for the four corners of the cell containing the coordinates to be processed are interpolated using the bilinear interpolation technique. d c d f c +------------+ +----+-------+ | | | | | | | | |p | | | h +----o-------+ g | | | { | | | | | x |~~~y~~~| | | | { | | +------------+ +----+-------+ b a b e a Consider the unit square with shift values (a,b,c,d) at the corners, as illustrated above. That is to say, the shifts are: a at (0,0), b at (1,0), c at (0,1), and d at (1,1). The objective is to determine the shift p at (x,y), where 0