|
From: <js...@us...> - 2010-07-28 18:37:32
|
Revision: 8587
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8587&view=rev
Author: jswhit
Date: 2010-07-28 18:37:26 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
update to new version from pyproj svn
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py 2010-07-28 18:35:18 UTC (rev 8586)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py 2010-07-28 18:37:26 UTC (rev 8587)
@@ -80,13 +80,15 @@
degrees. If optional keyword 'errcheck' is True (default is
False) an exception is raised if the transformation is invalid.
If errcheck=False and the transformation is invalid, no
- exception is raised and 1.e30 is returned.
+ exception is raised and 1.e30 is returned. If the optional keyword
+ 'preserve_units' is True, the units in map projection coordinates
+ are not forced to be meters.
Works with numpy and regular python array objects, python
sequences and scalars.
"""
- def __new__(self, projparams=None, **kwargs):
+ def __new__(self, projparams=None, preserve_units=False, **kwargs):
"""
initialize a Proj class instance.
@@ -121,6 +123,12 @@
>>> x,y = p2(-120.108, 34.36116666)
>>> print 'x=%9.3f y=%11.3f' % (x,y)
x=765975.641 y=3805993.134
+ >>> p = Proj(init="epsg:32667")
+ >>> print 'x=%12.3f y=%12.3f (meters)' % p(-114.057222, 51.045)
+ x=-1783486.760 y= 6193833.196 (meters)
+ >>> p = Proj("+init=epsg:32667",preserve_units=True)
+ >>> print 'x=%12.3f y=%12.3f (feet)' % p(-114.057222, 51.045)
+ x=-5851322.810 y=20320934.409 (feet)
"""
# if projparams is None, use kwargs.
if projparams is None:
@@ -133,13 +141,13 @@
projstring = projparams
else: # projparams a dict
projstring = _dict2string(projparams)
- # make sure units are meters.
- if not projstring.count('+units='):
+ # make sure units are meters if preserve_units is False.
+ if not projstring.count('+units=') and not preserve_units:
projstring = '+units=m '+projstring
else:
kvpairs = []
for kvpair in projstring.split():
- if kvpair.startswith('+units'):
+ if kvpair.startswith('+units') and not preserve_units:
k,v = kvpair.split('=')
kvpairs.append(k+'=m ')
else:
@@ -370,9 +378,9 @@
initialize a Geod class instance.
Geodetic parameters for specifying the ellipsoid
- can be given in a dictionary 'initparams', as keyword arguments,
+ can be given in a dictionary 'initparams', as keyword arguments,
or as as proj4 geod initialization string.
- Following is a list of the ellipsoids that may be defined using the
+ Following is a list of the ellipsoids that may be defined using the
'ellps' keyword:
MERIT a=6378137.0 rf=298.257 MERIT 1983
@@ -486,6 +494,9 @@
else:
kvpairs.append(kvpair+' ')
initstring = ''.join(kvpairs)
+ # first try a Proj class (catches errors properly)
+ projstring = initstring + ' +proj=latlon'
+ p = Proj(projstring) # this is never used
return _Geod.__new__(self, initstring)
def fwd(self, lons, lats, az, dist, radians=False):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2010-08-30 15:18:46
|
Revision: 8671
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8671&view=rev
Author: jswhit
Date: 2010-08-30 15:18:39 +0000 (Mon, 30 Aug 2010)
Log Message:
-----------
update tests to check for installation of datum grid files.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py 2010-08-29 13:27:14 UTC (rev 8670)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/pyproj.py 2010-08-30 15:18:39 UTC (rev 8671)
@@ -258,7 +258,7 @@
>>> print '%9.3f %11.3f' % (x1,y1)
569704.566 4269024.671
>>> print '%9.3f %11.3f' % (x2,y2)
- 569706.333 4268817.680
+ 569722.342 4268814.027
>>> print '%8.3f %5.3f' % p2(x2,y2,inverse=True)
-92.200 38.567
>>> # process 3 points at a time in a tuple
@@ -271,11 +271,18 @@
567703.344 351730.944 728553.093 4298200.739 4353698.725 4292319.005
>>> xy = x2+y2
>>> print '%9.3f %9.3f %9.3f %11.3f %11.3f %11.3f' % xy
- 567705.072 351727.113 728558.917 4297993.157 4353490.111 4292111.678
+ 567721.149 351747.558 728569.133 4297989.112 4353489.644 4292106.305
>>> lons, lats = p2(x2,y2,inverse=True)
>>> xy = lons+lats
>>> print '%8.3f %8.3f %8.3f %5.3f %5.3f %5.3f' % xy
-92.220 -94.720 -90.370 38.830 39.320 38.750
+ >>> # test datum shifting, installation of extra datum grid files.
+ >>> p1 = Proj(proj='latlong',datum='WGS84')
+ >>> x1 = -111.5; y1 = 45.25919444444
+ >>> p2 = Proj(proj="utm",zone=10,datum='NAD27')
+ >>> x2, y2 = transform(p1, p2, x1, y1)
+ >>> print "%12.3f %12.3f" % (x2,y2)
+ 1402285.991 5076292.423
"""
# process inputs, making copies that support buffer API.
inx, xisfloat, xislist, xistuple = _copytobuffer(x)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|