How to Transform Points from Local Coordinate System to GPS
The short answer is only two words, affine fit.
Someone on my team found this algorithm online called affine fit. We used it to transform cartesian coordinates to GPS coordinates. I'm not an expert on this, but by using some carefully measured points, I was able to get within 3 centimeters of accuracy on the translation to GPS using the affine fit formula.
My use case
I'll explain my problem, so you can determine if this is the right method for you. I created a map of a warehouse using simultaneous localization and mapping (SLAM) in Robot Operating System (ROS). It was a 2D map using a typical grid, cartesian coordinate system.
When using the SLAM map, I could get my coordinates based on the the map but my requirements were to send my GPS coordinates to other systems. I needed to turn these local coordinates into GPS coordinates.
I tried many different solutions including fancy formulas that may or may not have been implemented correctly, but I kept getting inaccurate GPS results. Then I used affine fit and everything seemed to just work.
How I used affine fit
This algorithm works by taking in two arguments. The first argument is a set of points from my SLAM map. The second argument, are those exact same points but in GPS. After giving the function those two arguments, it returns an object that has a function on it called Transform. You pass the Transform function a point, it will return another point that is transformed.
I passed the Transform function my current location in cartesian coordinates and it returned a GPS coordinate.
I had the initial GPS coordinates of the warehouse because it was professionally surveyed. That way I had a few accurate GPS points to create my affine fit.