Showing posts with label Spatial Central Tendency. Show all posts
Showing posts with label Spatial Central Tendency. Show all posts

Tutorial: Accumulative Mean Center (Plug-in Method)

Here is post-intro. I just want this part to be snippet

Q: How has the mean center of Starbucks stores in Gangnam, Seoul changed over the years?

Before you begin this tutorial, do the following first:

Running the Spatial Analyzer

[1] Click the Processing menu at the top, then click Toolbox.
The Processing Toolbox panel will appear on the right side of the window.

If the Spatial Analyzer plugin is not installed, refer to "Installing Urban Analyzer".Processing Toolbox panel screenshot

[2] In the Processing Toolbox, expand the SpatialAnalyzer submenu and double-click Mean Center Tracker.

Mean Center Tracker in toolbox

[3] In the “Mean Center Tracker” window, set Start Field to open_year, then click Run.Mean Center Tracker parameters

[4] Execution Result:Execution result layer


Tutorial: Accumulative Mean Center (Manual Method)


Q: How has the mean center of Starbucks stores in Gangnam, Seoul changed over the years?

Before you begin this tutorial, do the following first:
The method presented in this practice relies on basic QGIS functionality but can be time-consuming for practical use. This practice is designed primarily for learning QGIS operations. For practical cumulative mean center calculation, use the plug-in method

Checking the Layer Attribute Table

With the sbucks layer selected in the Layers panel, press the F6 shortcut key.

Result: The attribute table for sbucks opens. We will use the open_year field to compute cumulative mean centers.

Attribute table showing open_year field


A. Cumulative Mean Center up to 2002

Tutorial: Mean Center, Median Center and Central Feature(Plug-in Method)


Q: Find the Median Center and Central Feature of Starbucks Stores in Gangnam, Seoul.

Before you begin this tutorial, do the following first:


Finding the Median Center and Central Feature

[1] At the top of the screen, click the Processing menu, then click Toolbox. The Processing Toolbox panel will appear on the right side of the window.

Open Processing Toolbox in QGIS

[2] In the Processing Toolbox, expand SpatialAnalyzer at the bottom. Under Spatial Central Tendency, double-click Centers (Mean Center, Median Center, Central Feature)





[3] In the Spatial Central Tendency window, ensure Median Center and Central Feature are checked, then click Run. (By default, Mean Center, Median Center, and Central Feature are selected.)Select Median Center and Central Feature options

Weight Field lets you compute weighted centers using an attribute instead of pure distance. Examples include seating capacity, sales revenue, or number of employees. If you choose “sales revenue,” the resulting mean or median center will shift toward higher-revenue areas.

Group Field computes centers separately for each category when your data is classified. For example, if there is an administrative-district attribute, selecting that field will calculate centers per district. This method is discussed further in cluster analysis.

Result

Three point layers representing the Mean Center, Median Center, and Central Feature are created.



Tutorial: Compute the Mean Center(Built-in Method)


Adding the Starbucks Layer

The locations of Starbucks stores in the Gangnam area of Seoul are added as point features on the QGIS canvas.

Starbucks points loaded on the QGIS canvas

For attribute information of this file, see Checking the Attribute Table.


Adding the Mean Center

[1] With the Starbucks layer selected, go to Vector → Analysis Tools → Mean Coordinate(s)...Opening the Mean Coordinate(s) tool in QGIS


[2] Confirm the input layer shows sbucks [EPSG:5179], then click Run.Mean Coordinate(s) tool parameters with EPSG:5179


[3] Result: The mean center point is added to the canvas.Mean center point displayed on the map
In the Mean Coordinate(s) tool:
• Weight field lets you compute a weighted mean center using an attribute (e.g., number of seats, sales volume, or employees). If you choose sales volume as the weight, the mean center reflects where sales are geographically concentrated.
• Unique ID field enables separate mean centers for each group. For example, if the administrative district is stored in an attribute, selecting that field will compute a mean center for each district.

Theory: Central Feature

The Central Feature in spatial analysis refers to the single object among all points that has the shortest total distance to all other points. In other words, it identifies the actual point considered the most central among the dataset. For example, suppose Starbucks branch managers in Seoul need to gather at one store for a meeting. The store that minimizes the total travel distance for all managers becomes the central feature.

The central feature is similar to the median center, but while the median center selects an arbitrary point in the analysis space, the central feature selects one of the actual data points. Therefore, identifying the central feature is generally easier than calculating a median center.

The central feature is defined as the actual point \( P_j \) that satisfies the following condition:

$$ P_j = \arg\min_{P_k \in \{P_1, P_2, \ldots, P_n\}} \sum_{i=1}^{n} d(P_k, P_i) $$

  • \( d(P_k, P_i) \) : the distance from point \( P_k \) to each other point \( P_i \)
  • \( P_j \): the point with the shortest total distance to all other points, i.e., the central feature

Unlike the mean center or median center, which are calculated center points, the central feature is an actual data point within the dataset. Typically, the Euclidean distance is used, but it can also be extended to network distance or weighted distance depending on the analysis context.

Application Examples

  • Identifying the most representative location among crime incidents (the core scene)
  • Finding the actual store located closest to the customer distribution center
  • Determining the accident site that is, on average, the nearest to all other traffic accident locations
  • Extracting the most centrally located public institution within a city

Theory: Median Center

Outliers and the Median

As an economy develops, income and wealth tend to concentrate in specific individuals or groups. When using the mean income as a standard, the presence of high-income earners increases the average, making it appear higher than what most people perceive as “typical.”

Although the mean is the most widely used measure of central tendency, social and natural phenomena often include outliers, and if we make interpretations or decisions based on such distorted central values, the outcomes can deviate from reality.

For example, in public policy, decisions are often made for the benefit of the middle or lower-income groups rather than the wealthy. In such cases, the median income is used more frequently than the mean. The median, which is less sensitive to outliers, is a descriptive statistic that better reflects the central tendency of skewed data. It refers to the middle value when data is sorted from smallest to largest.

For instance, in the dataset 1, 5, 10, 17, 97, the median is 10. The mean, however, is 60, which does not reasonably represent the overall trend of the data.

Median Center

In spatial data, a concept similar to the median is the median center. Like the mean center, one could compute the median center by identifying the median values of the X and Y coordinates individually. However, this method is rarely used in spatial analysis.

Instead, spatial analysts typically define the median center as the point that minimizes the total distance all other points must travel to reach it. For example, imagine that a group of soldiers on leave need to gather in a single location. The optimal meeting point—the one that requires the shortest total travel distance from all their locations—is the median center.

To calculate it, one must compute the distances from all data points to a potential center and iteratively find the point where the total distance is minimized.

This concept is known as the geometric median, L1 center, or Weiszfeld-based median center. It calculates the \((x, y)\) coordinate that minimizes the total Euclidean distance to all other points, as shown below:

$$\min f(x_m, y_m) = \sum_{i=1}^{n} \sqrt{(x_i - x_m)^2 + (y_i - y_m)^2}, \quad \textit{Median Center} = (x_m, y_m)$$

This function minimizes the sum of absolute distances. Unlike the mean, it cannot be solved with a simple formula and requires an iterative optimization method. A widely used approach is the Weiszfeld algorithm, an iterative method for calculating the geometric median. It repeatedly computes the center that minimizes the total distance to all points in space.

Application Examples

  • Facility location optimization: Find a location that minimizes the total distance for customers
  • Disaster response analysis: Use the median center of emergency calls to select initial response points
  • Public facility distribution analysis: Analyze the spatial median of the population
  • Optimal logistics hub placement: Select locations that minimize delivery distances
  • Rescue center placement: Determine the center of clustered rescue requests in disaster scenarios
Learn More: Weiszfeld Algorithm
  1. Set an initial center point \((x^{(0)}, y^{(0)})\).
  2. Repeat the following update formulas:
    $$x^{(k+1)}=\frac{\sum_{i=1}^{n}\dfrac{x_i}{d_i^{(k)}}}{\sum_{i=1}^{n}\dfrac{1}{d_i^{(k)}}}, \quad y^{(k+1)}=\frac{\sum_{i=1}^{n}\dfrac{y_i}{d_i^{(k)}}}{\sum_{i=1}^{n}\dfrac{1}{d_i^{(k)}}}$$
    where \(d_i^{(k)}=\sqrt{(x^{(k)}-x_i)^2+(y^{(k)}-y_i)^2}\), i.e., the distance from the center at iteration \(k\) to point \(i\).
  3. Stop when the change in the center is sufficiently small (convergence).