How do I convert coordinates to a Latitude & Longitude?

久未见 提交于 2019-11-28 10:16:11

Ask them what coordinate system they're using! (or if you got the dataset from some database, look at the metadata for the dataset and it should tell you. Otherwise I'd be skeptical of its value)

Most likely this is one of the state plane coordinate systems. They're for localized areas of the earth (kind of like UTM), and are frequently used for surveying.

You can use CORPSCON (or other GIS programs; ExpertGPS will do this if you have the GIS Option Pack but it's not free. I forget whether GPSBabel does conversion) to convert between lat/long and any of the state plane coordinate systems. You'll also need to know which datum the coordinates are in. WGS84 and NAD83 are very close but NAD27 is different.

MikeW

If you look at the first 2 lines of data, and subtract the latitude

47.7044 - 47.7741 = -0.06972 degrees

There are 60 nautical miles per degree of latitude, and 6076 feet per nautical mile.

-.06972 * 60 * 6076 = 25,415 ft

Subtracting the two 'Y' values:

260662 - 286031 = 25,409 ft

So indeed that seems to prove the X and Y values are in feet.

If you take any of the Y values, and convert back to degrees, for example

260622 ft / ( 6076 ft/nm ) / ( 60 nm/degree ) = .71
286031 ft / 6076 / 60 = .78

So subtracting those values from the latitudes of (47.70 and 47.77) gives you very close to exactly 47 degrees, which should be your y=0 point.

For longitude, a degree is 60 nautical miles at the equator and 0 miles at the poles. So the number of miles per degree has to be multiplied by the cosine of the latitude, so approx cos(47 degrees), or .68. So instead of 6076 nm per degree, it's about 4145 nm.

So for the X values,

1268314 ft / ( 4145 ft/nm ) / ( 60 nm/degree ) = 5.10 degrees
1269649 ft / 4145 / 60 = 5.10 degrees

These X numbers increase as the latitude increases (less negative), so I believe you should add 5.1 degrees, which means the X base point is about

-122.3 + 5.1 = 117.2 West longitude for your x=0 point.

This is roughly the position of Spokane WA.

So given X=1280532, Y=211374

Lat = 47 + ( 211374 / 6096 / 60 ) = 47.58
Lon = -117.2 - ( 1280532 / ( 6096 * cos(47.58)) / 60 ) = -122.35

Which is roughly equivalent to the given data 47.57 and -122.29

The variance may be due to different projections - the X,Y system may be a "flattened" projection as opposed to lat/long which apply to a spherical projection? So to be accurate you may yet need more advanced math or that open source library :)

This question may also be helpful, it contains code for calculating great circle distances:

Calculate distance between two latitude-longitude points? (Haversine formula)

There are many different coordinate systems. You need to find out the what the coordinate systems are for both the lat/lon's (e.g. WGS84 etc) and x/y's first (e.g. some sort of projected system probably).

Once you have that information there are several tools you can use to do conversions and manipulations. One example (of a free open source coding library) is proj4.

You've got good advice on coordinate systems already, so I'll just chime in with the library I've used with great success in the past.

Geotrans is approved for use by the US Department of Defence, so you can be sure that it is well tested. You can grab it from here:

http://earth-info.nga.mil/GandG/geotrans/index.html

That might not be the right link as that page talks about the application, not the library. I expect the library is in the Developers package. Licensing terms were very liberal from memory, but make sure you review the terms before using it commercially.

Edit:

An interesting discussion on Geotrans licensing can be found here:

http://www.mail-archive.com/debian-legal@lists.debian.org/msg39263.html
Bob Cross

Over here, I said this:

In Java, I would use the OpenMap converter from a point's expression in UTM to one using Latitude and Longitude (assuming a WGS-84 ellipsoid which is most commonly used in GPS).

OpenMap is open source and I would post a link to their download page but they have a short license script in the way. So, to avoid being rude, I won't deep link. Instead, head to their homepage and click Downloads.

That should either solve your problem directly or at least point you towards a useful algorithm.

I've used Brenor Brophey's gPoint PHP class to do this on a couple of occasions. Solid results, GPL code, and easily deployed. Recommended.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!