[OSM-dev] Convert from Spherical Mercator to WGS-84?
Mike N.
niceman at att.net
Sun Nov 29 01:58:44 GMT 2009
> I was unsure whether the OP was able to do coordinate conversions in
> principle and just didn't know how to access spherical mercator, or
> whether he didn't know how to use these tools at all?
I have definitely not taken the GIS:100 course! I could not manipulate
the epsg library arguments into cs2cs argments, but I found a Python
fragment that does what I need, so I'm set.
....
self.originShift = 2 * math.pi * 6378137 / 2.0
...
def MetersToLatLon(self, mx, my ):
"Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in
WGS84 Datum"
lon = (mx / self.originShift) * 180.0
lat = (my / self.originShift) * 180.0
lat = 180 / math.pi * (2 * math.atan( math.exp( lat * math.pi /
180.0)) - math.pi / 2.0)
return lat, lon
-------------- Reverse with cs2cs:
echo -180 45 | cs2cs +proj=latlong +datum=WGS84 +to +proj=merc +ellps=sphere
+a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m
+towgs84=0,0,0 +no_defs
More information about the dev
mailing list