VERIFIED SOLUTION i

How to create a weighted centroid based on a table of points that includes a weight column?


Products Affected MapInfo Pro™

 

How to create a weighted centroid based on a table of points that includes a weight column?

The WtAvg aggregate function provides a very direct way to calculate a weighted centroid. It is not necessary to add extra columns and populate them with CentroidX(obj) and CentroidY(obj) coordinate information for each point; this can be done directly as part of the weighted-average calculation.

A mappable table will need to exist that contains at least the following three fields: Longitude, Latitude, and a column that represents a number for each long/lat.
 
1) To calculate a weighted centroid, use Map > SQL Select, and select the table containing points and weighting data, and use the following formula in the 'Select Columns' field:

WtAvg(CentroidX(obj),{weight column}),WtAvg(CentroidY(obj),{weight column}) Below is a simple weighted centroid calculation. This example calculates the centroid of the population in the USCTY153 table, weighted by population (the Pop_1990 column):

SQL Select Query:

User-added image
  • Select Columns: WtAvg(CentroidX(obj),Pop_1990),WtAvg(CentroidY(obj) ,Pop_1990)
  • From Tables: USCTY153
2) The result is a query table which can then be saved as a separate table (Home>Save Copy As)
 
3) Finally, open the saved copy of the table (File>Open Table). To put the centroid on a map, create points for the table (Table>Create Points) using Column 1 for the X coordinate and Column 2 for the Y coordinate.
User-added image
UPDATED:  August 9, 2017