This program will map project a raw instrument

The procedure to project the input cube is output driven. That is, we
create an output map cube (as specified by the user) and at each output
pixel, compute its projected latitude/longitude using the projection
parameters. Using this coordinate we must search for that position in
the two input cubes (latitude/longitude). If found, we will have a
sub-pixel location that has a 1-1 correspondence with the raw instrument
pixel. An interpolator (nearest neighbor, bilinear, or cubic convolution)
is then used to compute a value for the output

Therefore the root of the problem is finding the latitude/longitude in the two input cubes as it is a 2-dimensional search. We do this by first creating two polynomial functions of a user-specified order (DEGREE), one for sample and one for line. These functions, f(lat,lon) = sample and g(lat,lon) = line, are derived using a least-squares computation by collecting a sparse set of control points (line,samp)-to-(lat,lon). The sparseness is controlled by the SINC and LINC. Unfortunately the polynomial is not accurate enough to supply the mapping to sub-pixel accuracy. The level of errors between the control points and the derived equations can be written to the RESIDUAL file for examination.

To achieve sub-pixel accuracy, we use the polynomials to get us close (generally within 6 pixels). Using this estimated location, two affine transforms are computed by collecting a small 3x3 window of control points. These equations are used to further refine the estimated location. We iterate this process until our estimated sample/line is within an acceptable tolerance (TOLERANCE) of latitude/longitude values contained in the two cubes (LATCUBE/LONCUBE) or until the number of iterations is exceeded (ITERATIONS).

Defining the output

- ProjectionName - Should be specified by the map file
- TargetName - Will be searched for in the FROM cube or can be specified by the user.
- EquatorialRadius and PolarRadius- Will be automatically computed from NAIF kernels or can be specified by the user.
- LatitudeType - Will be read from the map file if available,
otherwise will be set to the
latitude type of the LATCUBE - LongitudeDirection - Will be read from the map file if available,
otherwise will be set to the
longitude direction of the LONCUBE - LongitudeDomain - The
longitude domain will be 0-360 by default. - MinimumLatitude - Can be computed from the LATCUBE, read from the map file or user specified.
- MaximumLatitude - Can be computed from the LATCUBE, read from the map file or user specified.
- MinimumLongitude - Can be computed from the LONCUBE, read from the map file or user specified.
- MaximumLongitude - Can be computed from the LONCUBE, read from the map file or user specified.
- Scale or
PixelResolution - Can be computed^{1}from the input, read from the map file, or user specified in either meters/pixel (PixelResolution) or pixels/degree (Scale)

^{1}To compute the scale we find the number of pixels from pixel (1, 1) to pixel (nsamples, nlines) in the input cube: sqrt[(nsamples-1)^{2}+ (nlines-1)^{2}] And the angle across this line: acos(cos(latitude_point1) * cos(latitude_point2) * cos(longitude_point1 - longitude_point2) + sin(latitude_point1) * sin(latitude_point2)) The scale is equal to the number of pixels divided by the angle in pixels per degree.