SO GLOBEC grid and software John Klinck (klinck@ccpo.odu.edu) Executive Summary A set of grid lines is designed for the west side of the Antarctic Peninsula as a convenient way to locate stations or other points of interest. These lines measure distance (in km) alongshore and across shore based on the Universal Transverse Mercator projection. Latitude and Longitude are less convenient for locations because of the Northeast to Southwest orientation of the coastline and shelf break. Also lat/lon are both in the range of -60 to -70 causing confusion as to which number is which. Programs in matlab and FORTRAN are provided to convert between lat/lon and x/y grid. Details on the use and structure of these routines are given below. This software is derived from conversion software (iplane.f) obtained from the US Geological Survey. Purpose The purpose of these routines is to provide a convenient distance based grid on which stations or other interesting locations on the west side of the Antarctic Peninsula (WAP) can be placed. Due to the across-shore and along-shore orientation of this grid, sections can be conveniently specified by one number. Quick Start The mapping projection used to construct this grid is Universal Transverse Mercator (UTM) which provides a conformal, distance-based coordinate system. UTM is the standard projection used by US State and Federal governments for mapping. The base point of the SOGLOBEC grid is 71S, 72W and the grid is rotated 60 degrees counterclockwise producing an x axis extending northeast parallel to the coast of the Antarctic Peninsula. This point in the far south of the Antarctic Peninsula was chosen so that anticipated stations will have a positive x coordinate. The origin of the grid system is shifted 50 km southeast (negative y direction or "onshore") so that all locations will have a positive y value. In fact, some locations have negative coordinates, but no further adjustments were made to the grid to avoid confusion. Two matlab functions are provided (grid2ll.m and ll2grid.m) to convert between grid and lat/lon. Grid values are distances (x,y) in kilometers alongshore (northeast) and across shore (northwest) from the base point. Latitude and longitude are in decimal degrees (negative for south latitude and west longitude). An initial routine (setuputm.m) sets the needed values for the conversion. Two test routines (testgetxy.m and testgetlatlon.m) check these conversions and illustrate their use. Similar fortran conversion routines (grid2ll.f and ll2grid.f) are provided along with a test shell script (maketest.csh). More Details The Mercator projection converts the spherical surface of the earth to a cylinder touching the earth at the equator and aligned with the spin axis (north pole). Cutting the cylinder anywhere along the long axis produces a flat map. One large benefit of this projections is that relative angles (bearings) between points is preserved. North-south distances are increasingly distorted away from the equator. A Transverse Mercator projection uses a cylinder which touches the earth along a chosen line of longitude, and thus is at right angles to the spin axis (or transverse). This mapping approximately preserves distances near the chosen longitude, but errors grow very large away from the central longitude and become infinity at longitudes that are 90 degrees away from the central longitude. The Universal Transverse Mercator projection, adopted by the US Army and other government agencies, divides the earth into 120 zones, each of which has a designated central longitude. The zones are mainly 6 degrees of longitude wide and cover the earth between 84N and 84S. Northern hemisphere zones are designated by positive numbers (1-60) while southern hemisphere zones are negative. Each zone is given a certain distance (in meters) for the location of the central point of the zone. This allows the edges of adjacent maps to join relatively smoothly. The west side of the Antarctic Peninsula is in zone -20. The base point for the SOGLOBEC grid is 71S, 72W which corresponds to the UTM coordinate (174032.74239707, 2098336.1384868). To orient the UTMx (east) coordinate to be along the Antarctic Peninsula, the coordinate system needs to be rotated 60 degrees counterclockwise. So, the (WAPx,WAPy) grid system is constructed from the (UTMx,UTMy) system by subtracting the UTM coordinates above and rotating by 60 degrees. As a final minor correction, the origin of the SOGLOBEC grid system is shifted southeast (minus y) by 50 km. The resulting numbers are the coordinates of the grid system. For convenience, the SOGLOBEC grid numbers are converted to kilometers. Software The following software performs the conversion from latitude/longitude to UTM grid values followed by the shift of origin and rotation needed to obtain the SOGLOBEC grid values. The original software (called iplane.f) to convert between lat/lon and UTM was written in FORTRAN by Jack Waananen of the US Geological Survey. C******************************************************************** C PROGRAM PLANE-PC C INTERACTIVE GRID COORDINATES CONVERSION C JACK WAANANEN C U.S. GEOLOGICAL SURVEY C NATIONAL CENTER MAIL STOP 521 C RESTON, VIRGINIA 22092 C 703-648-4509 VERSION OF 6/17/86 C******************************************************************** matlab The relevant parts of the original iplane.f FORTRAN code were extracted and converted to matlab. All parts of the transformation are accomplished in two routines grid2ll or ll2grid which convert from the grid coordinates to lat/lon or vice versa, respectively. In order to specify the constants needed for the conversion, a routine setuputm.m must be called once before any conversions are attempted. Note that a vector of input values can be given to each of these routines to produce a vector of output values. In some applications, the SOGLOBEC grid number is given as a two part number separated by a decimal, as in 250.100. This is the same as the (x,y) pair (250,100). In most cases this is easy to work with although it is possible in some places to get negative coordinates (-50,-50) which would be -50.-50 which causes some routines not to work properly. Routines: grid2ll.m: converts SOGLOBEC grid values (in km) to lat/lon. [lat,lon] = grid2ll(xgrid,ygrid); ll2grid.m: converts lat/lon to SOGLOBEC grid values (in km). [xgrid,ygrid] = ll2grid(lat,lon); setuputm.m: sets the values of global variables need for the conversion. Call this routine once at the start of a matlab session in which conversion are done. setuputm(); utm2xy.m: converts between decimal and paired number formats. This procedure does not work for negative coordinates. [xgrid,ygrid]=utm2xy(utm_loc) xy2utm.m: converts between paired number and decimal formats. This procedure does not work for negative coordinates. [utm_loc]=xy2utm(xgrid,ygrid) getlatlon.m: This routine is an example of converting from grid to lat/lon taking a set of values from a file and writing an output file. The particular values used have known conversions so the routines can be checked. getxy.m: This routine is an example of converting from lat/lon to grid values taking a set of values from a file and writing an output file. The particular values used have known conversions so the routines can be checked. testgrid2ll.m: This script tests the grid to lat/lon converter against known values in the files provided. testll2grid.m: This script tests the lat/lon to grid converter against known values in the files provided. FORTRAN The original version of this software was written in FORTRAN based on the iplane.f routines. A number of special case subroutines are provided in the iplane.f software which are not needed for the SOGLOBEC application, so these routines are not included here. Because of the number of significant digits that are needed for this application, all FORTRAN variables are double precision (REAL*8). grid2ll.f: This subroutine converts between SOGLOBEC grid values (in km) and lat/lon in decimal degrees. The arguments to this routine are scalars so the conversions are done one point at a time. That is, the subroutine must be call for each point to be converted. subroutine grid2ll(xgrid,ygrid,lat,lon) ll2grid.f: This subroutine converts between lat/lon in decimal degrees and SOGLOBEC grid values (in km). The arguments to this routine are scalars so the conversions are done one point at a time. That is, the subroutine must be call for each point to be converted. subroutine ll2grid(lat,lon,xgrid,ygrid) ll2utm.f: This subroutine is a modified version of the original conversion software and is not called directly by the user. It is called by ll2grid. subroutine ll2utm(x,y,lat,lon,conv,iizone,ispher) utm2ll.f: This subroutine is a modified version of the original conversion software and is not called directly by the user. It is called by grid2ll. subroutine utm2ll(x,y,lat,lon,conv,iizone,ispher) dtan.f: Because of early problems with double precision calculations of tangent, this routine is included to provide consistent results across different computers. This routine is called by utm2ll and ll2utm. double precision function dtan(x) getlatlon.f: This program converts a series of SOGLOBEC grid values to lat/lon. It illustrates the use of the routine grid2ll. This program reads station values in the decimal format (x.y) from standard in and calculates lat/lon which are printed to standard output. getlatlon < Test/testll.in > testll.out getxy.f: This program converts a series of lat/lon pairs to SOGLOBEC grid values. It illustrates the use of the routine grid2ll. This program reads lat/lon (either decimal degrees or degree and minute values) from standard in and calculates SOGLOBEC grid values which are printed in decimal format (x.y) to standard output. If lat/lon is provided as degrees and minutes then this routine converts to decimal degree. getxy < Test/testxy.in > testxy.out maketest.csh: This is a UNIX c-shell script which test these conversion routines. The output of each conversion is tested against correct values to assure that the routines are working correctly. Comments and corrections should be sent to John Klinck (klinck@ccpo.odu.edu)