On Nov 28, 2009, at 5:58 PM, Mike N. wrote:
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
The MetersToLatLon looks good, but careful with the cs2cs command, as
that proj4 string for merc looks like the a variation on spherical
mercator (as there are several).
More python examples below if you are into python (the first link
includes the proj4 string for mercator that will match the
MetersToLatLon result).
Dane
http://mapnik-utils.googlecode.com/svn/example_code/longlat_merc_conversion/
http://mapnik-utils.googlecode.com/svn/sandbox/tools/nikproj/nikproj.py
http://mapnik-utils.googlecode.com/svn/example_code/proj_transform/
_______________________________________________
dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/dev