The attached pdf gives examples of how to use the somewhat hidden recfunctions module which is buried in the depths of NumPy. To make a long story short... it facilitates working with tabular data: This includes adding and removing fields etc etc.
When combined with:
NumPy , you have an incredible set of tools to perform operations and calculations on geometry and attribute data.
The example in the attached document outlines the process of converting a shapefile's table to a structured array. From there, two new fields are added to contain the results of a radial sort of points about a determined center point within the point data set. The other field contains the results of the distance to the center point from each individual point.
What could this be used for? Well, in conjunction with numpy array functions...a lot. Here are some of the things I have dabbled with.
- sorting points: in a variety of fashions including
- flipping them,
- sort by X or Y, sort lexicographically,
- sort by distance (closest/farthest),
- radial sort etcetera
- order points to another point order prior to forming them into polylines or polygons (ie. to form a variant of the concave hull)
- determine the nearest/farthest-N points to a point of interest
- produce origin-destination pairs from points
- re-order fields
- plus more...