<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 28, 2009, at 5:58 PM, Mike N. wrote:</div><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font> I have definitely not taken the GIS:100 course! I could not manipulate <br>the epsg library arguments into cs2cs argments, but I found a Python <br>fragment that does what I need, so I'm set.<br><br>....<br> self.originShift = 2 * math.pi * 6378137 / 2.0<br>...<br>def MetersToLatLon(self, mx, my ):<br> "Converts XY point from Spherical Mercator EPSG:900913 to lat/lon in <br>WGS84 Datum"<br><br> lon = (mx / self.originShift) * 180.0<br> lat = (my / self.originShift) * 180.0<br><br> lat = 180 / math.pi * (2 * math.atan( math.exp( lat * math.pi / <br>180.0)) - math.pi / 2.0)<br> return lat, lon<br><br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><blockquote type="cite"><div> -------------- Reverse with cs2cs:<br><br>echo -180 45 | cs2cs +proj=latlong +datum=WGS84 +to +proj=merc +ellps=sphere <br>+a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m <br>+towgs84=0,0,0 +no_defs<br><br><br></div></blockquote><div><br></div><div>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).</div></div><div><br></div><div>More python examples below if you are into python (the first link includes the proj4 string for mercator that will match the MetersToLatLon result).</div><div><br></div><div>Dane</div><div><br></div><div><div><a href="http://mapnik-utils.googlecode.com/svn/example_code/longlat_merc_conversion/">http://mapnik-utils.googlecode.com/svn/example_code/longlat_merc_conversion/</a></div><div><a href="http://mapnik-utils.googlecode.com/svn/sandbox/tools/nikproj/nikproj.py">http://mapnik-utils.googlecode.com/svn/sandbox/tools/nikproj/nikproj.py</a></div><div><a href="http://mapnik-utils.googlecode.com/svn/example_code/proj_transform/">http://mapnik-utils.googlecode.com/svn/example_code/proj_transform/</a></div><div><br></div></div></body></html>