Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Suppose I already have a way to compute the centroids of different geometry types:

  • Points (arithmetic mean of Cartesian coordinates).
  • Linestrings (polylines) (weighted mean of segment mid-points in Cartesian coordinates, weighted by great-circle distance).
  • Polygons (weighted mean of spherical triangle centroids converted to Cartesian coordinates, weighted by spherical triangle areas).

I've included my methods for computing each type of centroid, but they can probably be ignored.

According to the PostGIS documentation for ST_Centroid:

The centroid is equal to the centroid of the set of component Geometries of highest dimension (since the lower-dimension geometries contribute zero "weight" to the centroid).

The dimension here refers to points (0), lines (1) and polygons (2).

What is the most consistent way of defining the centroid if the geometries of highest dimension have undefined (ambiguous) centroids? There are two possibilities:

  1. The combined centroid is also undefined (I assume this is what ST_Centroid does).
  2. The combined centroid is equal to that of the geometries of highest dimension with non-zero weight. If a geometry has no defined centroid, then we give it zero weight.

An example ambiguous situation is an equally-spaced LineString going around the equator. In this case, the centre of mass is at the sphere's origin. Another situation is two hemispherical polygons, N and S, covering the whole sphere. If such ambiguous geometries are combined with a point, should the point be the centroid?

One possibility is to interpret the centroids physically: the Earth is an invisible sphere suspended by a string, such that it can rotate about its centre. The centroid is therefore the point at the southernmost point if a collection of features are present on the spherical surface and the sphere is allowed to spin until it comes to rest.

In this situation, it seems reasonable that if the sphere is covered by area polygons, then adding a single point (of infinitesimally small area) is sufficient to make it come to rest at that point.

share|improve this question
    
When a result is undefined, forcing the computation to produce some result is an arbitrary process. Thus, in this case, any objective answer has to refer to the purpose or the interpretation of the centroid. So: why are you computing centroids? What do you hope they will tell you about the features? –  whuber Dec 27 '12 at 17:49
    
Agreed; I've already decided to let the user (of my library) decide what to do for a single ambiguous case e.g. equator centroid. In this case I return undefined. My question is whether to also return undefined for [equator, point]. The main use case that I'm imagining is rotation of a globe to focus on the "middle" of a particular feature. It seems reasonable to fall back to lower dimension centroids. I suppose I want to know if this is mathematically/physically consistent, since it's a rare case anyway. –  Jason Davies Dec 27 '12 at 17:56
    
@whuber I've added a couple of paragraphs explaining the physical intuition. Since it's such a rare case, maybe it's safest to just return undefined for mixed geometries, the highest dimensions of which are ambiguous. –  Jason Davies Dec 27 '12 at 18:03
    
Thanks, but that doesn't clarify it for me (I can't even tell what "bottommost" would refer to). Why do you want to compute centroids? What are they intended to represent? People often use centers as proxies for points that optimize some distance-related function. In the plane, the barycenter (the usual interpretation of "centroid") minimizes the integral of the squared distance. If this is what you wish to generalize to the sphere, then (for example) the solution for the Equator is any point on the Equator and you may pick any one arbitrarily without fear of error. –  whuber Dec 27 '12 at 18:47
    
Yes, I'm after the spherical analogue of the planar barycenter, if such a thing exists. This is why I'm unsure about mixing integrals of different dimensions (points, lines and areas). My question is whether it's mathematically consistent to fall back to lower dimensions if there is an ambiguity. (BTW, for the Equator could you also pick a pole for its barycenter? Or indeed any point on the sphere?) –  Jason Davies Dec 27 '12 at 18:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.