views:

369

answers:

2

I have a table full of longitude/ latitude pairs in decimal format (e.g., -41.547, 23.456). I want to display the values in "Easting and Northing"/ UTM format. Does geopy provide a way to convert from decimal to UTM? I see in the code that it will parse UTM values, but I don't see how to get them back out and the geopy Google Group has gone the way of all things.

+2  A: 

Nope. You need to reproject your points, and geopy isn't going to do that for you.

What you need is libgdal and some Python bindings. I always use the bindings in GeoDjango, but there are other alternatives.

EDIT: It is just a mathematical formula, but it's non-trivial. There are thousands of different ways to represent the surface of the Earth. See here for a huge but incomplete list.

There are two parts to a geographic projection of the Earth-- a coordinate system and a datum. The latter is essentially a three-dimensional model of the planet. When you say you want to convert latitude/longitude points to UTM values, you're missing a couple of pieces of the puzzle.

Let's assume that your lat/long points are based on the WGS84 datum, because that's a pretty common standard for lat/long points these days. You want to convert those points to a UTM coordinate system. But to which UTM coordinate system? There are 60 of them.

hanksims
Thanks for your answer. I'm confused: why do I need to reproject (maybe I'm just not clear what you mean by that) the point when my UTM link above says it's just a math formula to convert from one to the other? Also, can you point me at the specific places in the GDAL or GeoDjango docs where the conversion is shown? I've dug through them and can't find what I'm looking for.
Tom
See my update, and feel free to ask for more help/clarification. I gotta get back to work for a moment.
hanksims
My current lat/ long pairs are all values from a Google Map. Is there a standard expected UTM system (for North American residents, if it matters)? Sorry to be so clueless on this. I figured it would be the same as going from degrees, minutes, seconds to decimals or vice-versa.
Tom
Where are you at in North America, and where do you have your data? SQL database? Are your datapoints continuously updated, or do you just have to do a one-time conversion?
hanksims
The US. Just a one-time conversion.
Tom
If you just have to convert the points one time, then your best bet is to install GDAL and covert the points using ogr2ogr, an included command-line utility. If you're trying to match your points to another geographic dataset, figure out what UTM zone and datum the other dataset is using, and convert your points to that. Otherwise, look at the map in the UTM Wikipedia page I linked above, find the zone your data is in, and convert to that (using the WGS84 datum, probably). Good luck!
hanksims
A: 

I think I may have over-complicated things. All I wanted was the dms values (so 42.519540, -70.896716 becomes 42º31'10.34" N 70º53'48.18" W). You can get this by creating a geopy point object with your long and lat, then calling format(). However, as of this writing, format() is broken and requires the patch here.

Tom