I couldn't find any library.function in python/pandas to convert coordinates from NAD83 standard to GPS lat/lon degreed.
Below is an example to reproduce the situation. I am looking for a function to convert these NAD83 coordinates to regular GPS lat/lon. All the points below are expected to be around St. Louis, MO
(i.e. approximately 38.6270° N
, 90.1994° W
).
xcoords = [894557.5, 880625.2, 896551.8, 896551.8, 896497.6, 903061.1]
ycoords = [1025952, 996012.7, 1025333, 1025333, 997157.3, 1033547]
df = pd.DataFrame({'xcoords':xcoords, 'ycoords':ycoords})
which means
xcoords ycoords
894557.5 1025952.0
880625.2 996012.7
896551.8 1025333.0
896551.8 1025333.0
896497.6 997157.3
903061.1 1033547.0
datasource = http://www.slmpd.org/Crimereports.shtml
metadata = http://www.slmpd.org/Crime/CrimeDataFrequentlyAskedQuestions.pdf (see XCoord and YCoord - what are these coordinates of/for?
)
First we need to determine the SPCS or FIPS zone for St. Louis, MO. From the NOAA Manual NPS NGS 5 we get zone # 2401. Then we download the corresponding proj string from special reference (alternatively you can take the necessary data from appendix A, page 68 of the NOAA Manual). With these data we can convert the SPCS data to gps lon/lat values using pyproj:
import pandas as pd
import pyproj
xcoords = [894557.5, 880625.2, 896551.8, 896551.8, 896497.6, 903061.1]
ycoords = [1025952, 996012.7, 1025333, 1025333, 997157.3, 1033547]
df = pd.DataFrame({'xcoords':xcoords, 'ycoords':ycoords})
fips2401 = pyproj.Proj("+proj=tmerc +lat_0=35.83333333333334 +lon_0=-90.5 +k=0.9999333333333333 +x_0=250000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs")
wgs84 = pyproj.Proj("+init=EPSG:4326")
df[['lon', 'lat']] = pd.DataFrame(pyproj.transform(fips2401, wgs84, df.xcoords.to_numpy(), df.ycoords.to_numpy())).T
Result:
xcoords ycoords lon lat
0 894557.5 1025952.0 -90.239655 38.650896
1 880625.2 996012.7 -90.288682 38.568784
2 896551.8 1025333.0 -90.232678 38.649181
3 896551.8 1025333.0 -90.232678 38.649181
4 896497.6 997157.3 -90.233154 38.571814
5 903061.1 1033547.0 -90.209794 38.671681