## Topo Coordinate Conversion

This work addresses the problem of converting pixel coordinates in USGS topographic maps (on the website at www.efghmaps.com) to latitude and longitude, and vice-versa.

Notice that longitude increases from left to right (it is always negative in the San Diego area), and that longitude increases from bottom to top. The pixel row number increases from top to bottom, and the pixel column number increases from left to right. Row and column numbers are supplied by most image editing programs.

It is assumed that row numbers and column numbers map linearly to latitude and longitude, respectively. This is a reasonably close approximation for 7.5-minute quadrangle maps at reasonably low latitudes. It would not work well for much larger maps or for maps at high latitudes.

The magnitude of this error can be estimated by a simple computation. One of the northernmost quadrangles extends from 33.5 degrees N to 33.625 degrees N, and it is 0.125 degrees wide. The length of a great circle is approximately 24860 miles. Then the lengths of the top and bottom sides of the map are given by

```length of top = 24860 miles * (0.125 / 360) cos(33.625 deg) = 7.1876449 miles
length of bottom = 24860 miles * (0.125 / 360) cos(33.5 deg) = 7.1980561 miles
```
The difference is 7.1980561-7.1876449 = 0.0104112 miles, or about 55 feet.

Although the corners of topographic maps are supposed to be on 7.5-minute boundaries, many are not, and it can be difficult to determine latitude and longitude from the maps alone.

Therefore, the technique used here is to identify known points on the maps, such as street intersections or benchmarks, get their latitudes and longitudes from a GPS ground survey or other source, and use a least-squares approximation to interpolate or extrapolate to other points.

Some points are taken from surveys of streets and highways, which can be plotted and fitted against a map, even if individual points on them are not identifiable either on the map or on the ground.

The database TOPOCONV.DBF (which is not posted on the website) contains the coversion coefficents as follows:

```field name  type  width  precision  description
----------  ----  -----  ---------  ----------------------------------
LATDEGREE    N       3       0      degrees of N latitude of SE corner
LATMINUTE    N       5       1      minutes of N latitude of SE corner
LONDEGREE    N       3       0      degrees of W longitude of SE corner
LONMINUTE    N       5       1      minutes of W longitude of SE corner
LATA         N      11       6      scaled slope of latitude/row fit
LATB         N      11       6      intercept of latitude/row fit
LONA         N      11       6      scaled slope of longitude/column fit
LONB         N      11       6      intercept of longitude/column fit
MAXERROR     N       5       0      maximum error of fit (in feet)
RMSERROR     N       5       0      RMS error of fit (in feet)
```

The slopes LATA and LONA are scaled by 100000 so they can be fitted into the fields provided for them. That is, the value in the database is 100000 times as large as the actual value.

The approximate latitude and longitude (in degrees) of the pixel in a specified row and column are given by

```LATITUDE = LATA * ROW + LATB
LONGITUDE = LONA * COLUMN + LONB
```

The approximate pixel coordinates of a point at a specified latitude and longitude can be computed by solving for ROW and COLUMN:

```ROW = (LONGITUDE - LONB) / LONA
COLUMN = (LATITUDE - LATB) / LATA
```

The coefficients are computed by fitting straight lines to data from the database TOPODATA.DBF, which has latitude, longitude and row and column numbers for a number of specific points. (It is not posted on the website.) The fields are as follows

```field name  type  width  precision  description
----------  ----  -----  ---------  --------------------