In ArcGIS 10.0, how do I calculate the weighted centroid of a collection of polygons, where I want the weight to be a raster layer. In particular I am using a raster of population counts and would like to generate the population weighted centroid as a result.
|
There's a neat trick: you can create grids of row and column indexes by performing FlowAccumulation calculations on constant grids, as in For your purposes that's good enough. When you really need $$XMap and $$YMap, rescale the row/column indexes by the cellsize and shift by the origin (plus, perhaps, another half a cellsize in both directions to obtain coordinates of cell centers). No scripting needed (and much faster in execution, too)! Now to answer your question: convert the polygons to grid format after first computing the population per unit area. Call this grid [density], because it's a population density. Compute [row index] and [column index] grids as shown above. To obtain the x-coordinates of the centroids, divide the zonal sums of [density]*[column index] by the zonal sums of [density] (there's one of each per polygonal zone). Do a similar operation with the row indexes to obtain the y-coordinates of the centroids. If desired, convert these centroids (which are averaged row/column indexes) to coordinates by scaling by the cellsize and adding the coordinates of the origin (plus one-half the cellsize). |
|||||||||||
|
|
This post on ESRI forums provides the logic on using $$XMap, $$YMap, some map algebra, and zonal summaries to come up with the x and y coordinates for each weighted centroid. The following code is my attempt at replicating the now removed $$XMap and $$YMap grid expressions in python in ArcGIS 10.0:
At this point I have rasters of both x and y coordinates and can continue on using the logic in the above link. |
||||
|
|
