[Gdal-dev] osgeo.osr: WGS84 to UTM/UPS coordinate conversion - howtodo?

Marco Nicoletti nicoletti at consorzio-innova.it
Mon Oct 12 04:43:07 EDT 2009


Ok,

about the WSG84 to UTM, I can fin the UTM Zone easily:
>>from osgeo import osr
>>def UTMZone(lon, lat):
>>return int((lon + 180) / 6) + 1 

The problems are:
1) from WGS84 to UPS
2) from UPS to WSG84

How to do it?

Thanks!


Marco Nicoletti wrote:
> 
> Dear all,
> 
> I got some problems in using the osgeo.osr library to convert from WGS84
> (lat,lon) coordinates to UTM/UPS carthographic projection.
> 
> From UTM (zone=33, for example) to WGS84 it seems easy:
>>> wgs84 = osr.SpatialReference()
>>> wgs84.SetWellKnownCS('WSG84')
>>> utm = osr.SpatialReference()
>>> utm.SetUTM(33)
>>> conv_wgs2utm = osr.CoordinateConversion(wgs84, utm)
>>>conv_wgs2utm.TransformPoint(lon, lat)
> 
> It seems to work; now I miss:
> 1) from UPS to WGS84
> 2) from WGS84 to UTM/UPS (reusing the code I wrote, I could create a
> convertitor in the 
> other direction - conv_utm2wgs =  osr.CoordinateConversion(utm, wgs84);
> but I need to specify the 
> UTM zone before - actually I should not have the UTM zone before
> converting! )
> 
> Do you have some example code I can use???
> 
> Thanks so much!
> 
> Marco Nicoletti
> 

-- 
View this message in context: http://n2.nabble.com/osgeo-osr-WGS84-to-UTM-UPS-coordinate-conversion-howtodo-tp3806702p3806774.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list