# Formula to convert xy to long-lat coordinates given a point

I need to figure out how to convert my xy coordinates to longitude and latitude.

I do not need the exact conversion, just an approximate so I can plot it in a mapping API. I managed to estimate the following xy to long-lat:

(x, y) = 24050, 123783.3333 -> (long, lat) = (122.98, 24.46)

(x, y) = 24216.6667, 123933.3333 -> (long, lat) = (122.985339, 24.46041)

Can I somehow use these to come-up with a formula to convert the other xy points?

I found another link that does what I want, but I cannot extract the formula:

http://www.whoi.edu/marine/ndsf/cgi-bin/NDSFutility.cgi?form=0&from=XY&to=LatLon

In the above link, I specify the origin of xy in lat-long coordinates, and it was able to convert xy to lat-lang

• Why can't you get the formula? It is clearly defined in the Javascript code: whoi.edu/marine/ndsf/utility/NDSFutility.js starting in line 289. – Spacedman Dec 19 '16 at 8:08
• Sorry that was not clear, I was able to access the javascript file but I cannot pinpoint the formula that I should follow. – curious kid Dec 19 '16 at 8:28
• Its the `translate_coordinates` function, which does a bunch of stuff with sines and cosines depending on the values in the formula boxes. Do you understand javascript? What language would you want to convert this to for your purposes? Also, note its not a perfect algorithm, and the web site can give nonsense lat-long for large offsets. – Spacedman Dec 19 '16 at 10:33
• would you please confirm that the excel sheet uwgb.edu/dutchs/UsefulData/HowUseExcel.HTM is still available. Would y – WokiriJ Mar 19 '18 at 13:24
• that page is dead, but I've linked another source – Sir Adelaide Sep 12 '18 at 6:29

## 2 Answers

It is complex, due to curvature of the earth effects and where on Earth you are.

I would recommend reading this page:

http://www.geosci.usyd.edu.au/users/prey/Teaching/Geos-2111GIS/Practicals/UTMConvDutch.xls

If you can replicate what the spreadsheet is doing in your API, you'll have your answer.

Exactly how you do that depends on the language you're using, and I presume you've got the programming skill to do that part.

• Thanks for this. But I think the x,y coordinates that I provided is in Mercator Projection. I found another link that does what I want, but I cannot extract the formula: whoi.edu/marine/ndsf/cgi-bin/… In the above link, I specify the origin of xy in lat-long coordinates, and it was able to convert xy to lat-lang – curious kid Dec 19 '16 at 6:47
• The link I gave is for UTM projection, which stands for Universal Transverse Mercator, i.e. its what you want. But you'll need to know which zone you are in for the spreadsheet to give answers. You can use Google Earth, and set the coordinate system to UTM. It will say in the bottom right zone plus coordinates of the current view. Go to your area and find your zone, then the UTM conversion spreadsheet will become useful. – Sir Adelaide Dec 19 '16 at 7:02

//Sample "convert xy to latlong" by pod ArcGis:

``````for item in (GeometryDataXYValue)!{
let xValue = item.paths?.ofX
let yValue = item.paths?.ofY

//recieve x y point
currentPoint = AGSPoint(x: xValue!, y: yValue!, spatialReference: AGSSpatialReference.webMercator())

//convert to lat long by AGSSpatialReference.wgs84()

if  let aReference = AGSGeometryEngine.projectGeometry(currentPoint!, to: AGSSpatialReference.wgs84()) as? AGSPoint {
currentPoint = aReference
}
}
var long:Double = currentPoint!.x
var lat: Double = currentPoint!.y
print("value long lat =  \(long , lat)")
}
``````
• not sure what pod ArcGIS means, can you clarify in your answer. – nmtoken Jul 20 '18 at 8:33
• I use pod of ArcGIS to import some process method in map to bring use in my code use method for convert data point xy to lat long. if you use another map I think you can't use this method – Papon Smc Jul 23 '18 at 6:46
• this is pod developers.arcgis.com/ios – Papon Smc Jul 23 '18 at 6:47