diff --git a/lib/matplotlib/projections/geo.py b/lib/matplotlib/projections/geo.py index 926a22fa5de5..9f4730301761 100644 --- a/lib/matplotlib/projections/geo.py +++ b/lib/matplotlib/projections/geo.py @@ -269,24 +269,23 @@ def __init__(self, resolution): self._resolution = resolution def transform_non_affine(self, ll): - longitude = ll[:, 0:1] - latitude = ll[:, 1:2] + longitude = ll[:, 0] + latitude = ll[:, 1] # Pre-compute some values half_long = longitude / 2.0 cos_latitude = np.cos(latitude) alpha = np.arccos(cos_latitude * np.cos(half_long)) - # Mask this array or we'll get divide-by-zero errors - alpha = ma.masked_where(alpha == 0.0, alpha) - # The numerators also need to be masked so that masked - # division will be invoked. + # Avoid divide-by-zero errors using same method as NumPy. + alpha[alpha == 0.0] = 1e-20 # We want unnormalized sinc. numpy.sinc gives us normalized - sinc_alpha = ma.sin(alpha) / alpha + sinc_alpha = np.sin(alpha) / alpha - x = (cos_latitude * ma.sin(half_long)) / sinc_alpha - y = (ma.sin(latitude) / sinc_alpha) - return np.concatenate((x.filled(0), y.filled(0)), 1) + xy = np.empty_like(ll, float) + xy[:, 0] = (cos_latitude * np.sin(half_long)) / sinc_alpha + xy[:, 1] = np.sin(latitude) / sinc_alpha + return xy transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__ def transform_path_non_affine(self, path):