matplotlib / matplotlib/basemap

support pandas Series as input for lat/lon -> x/y conversion

Open
#232 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
817
Forks
395
PR merge metrics
No merged PRs in 30d

Description

Using `pd.Series()` as input for lat/long -> x/y conversion does currently raise a RuntimeError:

``` python
x,y = map_katins(df["lon"], df["lat"])
RuntimeError Traceback (most recent call last)
in ()
15 # map_katins.plot(x, y, "ro", markersize=10)
16 x,y = map_katins(df["lon"].values, df["lat"].values)
---> 17 x,y = map_katins(df["lon"], df["lat"])
18 map_katins.plot(x, y, "o", color="grey", markersize=5)
19

C:\portabel\miniconda\envs\katins\lib\site-packages\mpl_toolkits\basemap\__init__.pyc in __call__(self, x, y, inverse)
1146 except TypeError:
1147 y = [_dg2rad*yy for yy in y]
-> 1148 xout,yout = self.projtran(x,y,inverse=inverse)
1149 if self.celestial and inverse:
1150 try:

C:\portabel\miniconda\envs\katins\lib\site-packages\mpl_toolkits\basemap\proj.pyc in __call__(self, *args, **kw)
284 outxy = self._proj4(xy, inverse=inverse)
285 else:
--> 286 outx,outy = self._proj4(x, y, inverse=inverse)
287 if inverse:
288 if self.projection in ['merc','mill','gall']:

C:\portabel\miniconda\envs\katins\lib\site-packages\mpl_toolkits\basemap\pyproj.pyc in __call__(self, *args, **kw)
386 _proj.Proj._inv(self, inx, iny, radians=radians, errcheck=errcheck)
387 else:
--> 388 _proj.Proj._fwd(self, inx, iny, radians=radians, errcheck=errcheck)
389 # if inputs were lists, tuples or floats, convert back.
390 outx = _convertback(xisfloat,xislist,xistuple,inx)

_proj.pyx in _proj.Proj._fwd (src/_proj.c:1571)()

RuntimeError:
```

Using

``` python
x,y = map_katins(df["lon"].values, df["lat"].values)
```

works...

``` python
import mpl_toolkits.basemap
mpl_toolkits.basemap.__version__
'1.0.7'
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure at the map_katins(df["lon"], df["lat"]) entry point and compare it with the working .values calls, using the Basemap 1.0.7 context provided. Trace the conversion into the Basemap projection call and identify the existing regression-test location; done means pandas Series inputs convert without the RuntimeError while existing array inputs continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.