[Numpy-discussion] Re: Format of arrays to facilitate analysis

2025-02-18 Thread Dan Patterson
So from a purely numpy perspective, there is no advantage if one of 
aforementioned coordinate arrangements is used (eg Nx2, ravelled, 2xN).
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Format of arrays to facilitate analysis

2025-02-18 Thread Robert Kern via NumPy-Discussion
On Tue, Feb 18, 2025 at 11:06 AM Dan Patterson 
wrote:

> I tend to work with Nx2 arrays representing coordinate geometry.
> I have examined a number of packages and there is no guidelines as to why
> a certain arrangement is preferred over the other.
> For example:  a rectangle, coordinates ordered clockwise with the first
> and last the same to ensure closure of the geometry
>

That's the great thing about conventions; there are so many to choose from!
/sarcasm

Usually, there is nothing substantial that would cause one to strongly
prefer one convention over another. I usually take a look at existing
libraries that I might want to use and pick a convention that makes it easy
to use those libraries. So for use cases like this, I might want to use
Shapely for some robust geometrical operations, so I'd follow Shapely
conventions. But if I'm just drawing polygons onto images, I might follow
scikit-image's convention instead.

By and large, you can usually safely follow whatever is your personal
preference without fearing that you are missing out on something vital.
What makes these conventions are the low stakes.

-- 
Robert Kern
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Format of arrays to facilitate analysis

2025-02-18 Thread Dan Patterson
I tend to work with Nx2 arrays representing coordinate geometry.
I have examined a number of packages and there is no guidelines as to why a 
certain arrangement is preferred over the other.
For example:  a rectangle, coordinates ordered clockwise with the first and 
last the same to ensure closure of the geometry

as a numpy ndarray
array([[  0.00,   0.00],
  [  0.00,   2.00],
  [  8.00,   2.00],
  [  8.00,   0.00],
  [  0.00,   0.00]])

same, but just ravelled
array([  0.00,   0.00,   0.00,   2.00,   8.00,   2.00,   8.00,   0.00,   0.00,  
 0.00])

How about a T

array([[  0.00,   0.00,   8.00,   8.00,   0.00],
  [  0.00,   2.00,   2.00,   0.00,   0.00]])

and of course there are the python  list equivalents of the above.

Preference/history seems to be the only guiding principle as to one chooses a 
certain coordinate layout over another.
Nx2 for 2D coordinates makes sense to me ( eg X, Y graphs,  Longitude, Latitude)

If I were to profer a reason to another person why I chose a particular format 
over another other than "works for me", would there be any other guiding 
considerations?

In general I:
- work with the coordinates as a pair
- sometimes, just the 'X' or 'Y'
- I save the values to disk on occasion so I can recover a particular entity 
without having to recreate it.

Curious... since I also worked with 3D coordinates (X, Y, Z as position and 
elevation) but I am considering working with temporal representation of 2D and 
3D data.  This is still ndim=2, but adding time as a the 3rd dimension

array([[[  0.00,   0.00],   # locations at time 0
   [  0.00,   2.00],
   [  8.00,   2.00],
   [  8.00,   0.00],
   [  0.00,   0.00]],

   [[ 10.00,  10.00],   # locations at time 2, shifted by 10, 10 in X, and Y
[ 10.00,  12.00],
[ 18.00,  12.00],
[ 18.00,  10.00],
[ 10.00,  10.00]]])
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com


[Numpy-discussion] Re: Format of arrays to facilitate analysis

2025-02-18 Thread Robert Kern via NumPy-Discussion
On Tue, Feb 18, 2025 at 3:00 PM Dan Patterson 
wrote:

> So from a purely numpy perspective, there is no advantage if one of
> aforementioned coordinate arrangements is used (eg Nx2, ravelled, 2xN).


No, not from numpy's side. Some things you want to do will be
easier/prettier in one of the arrangements than others (e.g. the ravelled
will likely be the least convenient), but it has more to do with other code
and file formats that you are interacting with that will be the largest
factors in breaking the symmetry.

-- 
Robert Kern
___
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com