A funny distance measure . . . and the power of spatial SQL

  • Posted on: 1 February 2012
  • By: deby
Average distance definition

We all know that distance computations are a common thing in many GIS projects, and that all serious spatial data systems allow you to perform such computations through a built-in function, often simply called distance. And everyone of us knows the square root definition for the case of point-to-point distances.

This notion of distance is based on minimal values, and equally easily one can define a notion of distance based on maximal values. Now, in the context of the work with Gaurav Singh, in an attempt to normalize distances occurring in different provinces, we needed to know what is the average distance of points in a polygon P to the centroid point c ('centre of mass') of P. By this, I really meant to find a computational realization ('implementation of an algorithm') of the formula as in the attached illustration above.

I have implemented such a function in PG SQL, and the full write-up is here: link into doodooland. The write-up defines the function and provides the full code to compute it from a PG database.

-- rdb