Take a square representing a polygon or a closed-loop polyline. Let us call it aoi, perhaps out area of interest.
aoi
array([[ 0.00, 0.00],
[ 0.00, 10.00],
[ 10.00, 10.00],
[ 10.00, 0.00],
[ 0.00, 0.00]])
aoi.shape
(5, 2)Notes:
- The first and last points are the same, hence it is a closed geometry
- The shape of the poly* feature is 5 rows (0 through 4 inclusive) and 2 columns ( 0 and 1), since python numbering is zero-based
Conceptually we know from out maths, that we just need to take the sequential difference between the points to get the differences in the x's and y's. Whip in a quick euclidean calculation courtesy of the right-angle triangle and other cringeful recollections of things numeric.