Ticket #85 (feature request)

Opened 2 years ago

Allow numpy arrays in _proj4.transform_points

Status: new

Reported by: seang Assigned to: seang
Priority: major Milestone:
Component: Spatial and Geometry Version:
Keywords: geometry numpy Cc: Chris.Barker@noaa.gov

From Chris Barker


Possible solutions:

* Robust and easy: Use PyList_Check and friends to type check before using the input list. (and tuple, etc). You could also pass in format strings to PyArgParseTuple() to do at least some type checking for you.

* More flexible: Use the PySequence* functions, so that the code will work on sequences other than lists of tuples (tuples of tuples, even numpy arrays). This is the most "pythonic" solution but can slow things down.

wxPython does this, through it's wxPointListHelper functions -- it takes any sequence of sequences of numbers, and branches to get optimum performance for each common sequence type.

You can use PySequence_Fast to help with that too.

* Better: Check for numpy arrays, and use the array interface it you get them. In addition to one of the above.

* Best ? Require numpy -- then you can use numpy's Turn-this-arbitrary-input-into-a-numpy-array function, and go from there with a known, robust C-array of data. Blazingly fast on numpy array inputs, and as fast as anything else on list, etc inputs, but you don't have to write all the type checking code--the numpy folks have done that.