[Gdal-dev] hi, how can I get the longitude/latitude information through OGR?

Mateusz Łoskot mateusz at loskot.net
Fri Jan 20 04:38:16 EST 2006


Jason wrote:
> Thanks. But, I am a software engineer lacking of GIS related 
> knowledge. Sorry for the stupid questions. But, how can I tranform 
> the x, y, z coordinated into longitude/latitude information formats, 
> like: 120 47' 7.19 '' E.
> 

You have to convert format of coordinates to that appropriate for your
application. Usually, you will play with 3 formats:

D M S - decimal-minutes-seconds
DD MM.MMMMMM - degrees with decimal-minutes
DD.DDDDDDDD - (decimal degrees)

> OGRPoint::getX() return a double format variable, so how can I 
> translate this value into longitude liked format.

If your coordinates are in lat/lon so you (most likely) have it in
decimal-degrees format (DD.DDDDDDD).

Here you have your coordinates (given above) converted from
DMS to DD.DDDDDD by Google:

http://www.google.pl/search?q=%28120+%2B+%2847%2F60%29+%2B+%287.19%2F3600

Here is also small piece of Python code with trivial functions
(equations + test cases) how to do it:

http://mateusz.loskot.net/software/gis/

Cheers
-- 
Mateusz Łoskot
http://mateusz.loskot.net



More information about the Gdal-dev mailing list