python - lat/lon to utm to lat/lon is extremely flawed, how come? -
i've tried following, input: lat/lon data i'll calculate box around by, let's 50 m, +/- 50 m on easting/northing value.
now reconvert lat/lon , script:
http://robotics.ai.uiuc.edu/~hyoon24/latlongutmconversion.py result can't be, lon before around 7, afterwards around 2.
zone, easting, northing = lltoutm(23, location.get_lat(), location.get_lon()) toputm = northing + error bottomutm = northing - error leftutm = easting - error rightutm = easting + error left, top = utmtoll(23, leftutm, toputm, zone)
is error in code, or might script flawed?
so i've tried use pyproj, lat/lon utm lat/lon see happens
>>> p = pyproj.proj(proj='utm', zone=32, ellps='wgs84') >>> p <pyproj.proj object @ 0x7ff9b8487dd0> >>> x,y = p(47.9941214, 7.8509671) >>> print x,y 5159550.36822 1114087.43925 >>> print p(x,y,inverse=true) (47.971558538495991, 7.8546573140162605)
and here it's not extremely far off script above, still seems enough incorrect not able use it. how come? can more exact results?
edit:
i ran test() , tests passed.
in epsg file there no such thing. closest i've found this:
<32632> +proj=utm +zone=32 +ellps=wgs84 +datum=wgs84 +units=m +no_defs <>
no tmerc. need pass towgs84 parameters? ones above?
i've created small utm conversion library python last week , uploaded python package index: http://pypi.python.org/pypi/utm
i have compared using pyproj , faster , more accurate. given sample data, result:
>>> import utm >>> u = utm.from_latlon(47.9941214, 7.8509671) >>> print u (414278, 5316285, 32, 't') >>> print utm.to_latlon(*u) (47.994157948891505, 7.850963967574302)
update: richards answer below describes real solution issue.
Comments
Post a Comment