Skip to content

Checking your reading list…

Retry verification

Stay curious. Build better.

Appearance

Choose how BestHub looks on this device.

Changes apply immediately.

Search articles

Open Discover with these filters

Suggested searches

Comparative Analysis of Starbucks and Luckin Coffee Store Distribution in China Using Python Data Visualization
Big Data 11 min read

Comparative Analysis of Starbucks and Luckin Coffee Store Distribution in China Using Python Data Visualization

Using Python data visualization and geospatial analysis, this article compares the nationwide distribution of Starbucks and Luckin Coffee stores in China, revealing differences in regional concentration, proximity patterns, and statistical insights such as average Luckin stores within 500 m of each Starbucks location.

This article demonstrates how to use Python for data visualization and geospatial analysis to compare the distribution of Starbucks and Luckin Coffee stores across China.

Two datasets (Starbucks and Luckin store locations for 2022) are accessed via API calls. The relevant fields include store name, longitude, latitude, and city.

import requests
headers = {"x-token": "你的鉴权token"}
response = requests.get("http://app.chafer.nexadata.cn/openapi/v1/sheet/sht22nId5uouP2/records?size=1&page=1", headers=headers)
print(response.json())

Data is fetched programmatically, concatenated into pandas DataFrames, and prepared for analysis.

# Import libraries
import pandas as pd
import requests
import time
from shapely.geometry import Point
from shapely.geometry.polygon import Polygon

# Fetch Starbucks data
starbucks_list = []
for i in range(1, 10):
    response_1 = requests.get("http://app.chafer.nexadata.cn/openapi/v1/sheet/sht22nId5uouP2/records?size=500&page={0}".format(i), headers=headers)
    starbucks = pd.DataFrame(response_1.json()['data']['list'])
    time.sleep(1)
    starbucks_list.append(starbucks)
starbucks = pd.concat(starbucks_list)

# Fetch Luckin data
luckin_list = []
for j in range(1, 9):
    response_2 = requests.get("http://app.chafer.nexadata.cn/openapi/v1/sheet/sht22nIeomVmYy/records?size=500&page={0}".format(j), headers=headers)
    luckin = pd.DataFrame(response_2.json()['data']['list'])
    time.sleep(1)
    luckin_list.append(luckin)
luckin = pd.concat(luckin_list)

Geospatial functions are defined to create a 500‑meter radius circle around each Starbucks store and to test whether Luckin stores fall within that circle.

# Create circular polygon (radius in meters)
def circle(data, radius):
    center_latitude = float(data['维度'])
    center_longitude = float(data['经度'])
    center_point = Point(center_longitude, center_latitude)
    circle = center_point.buffer(radius/111300)
    return Polygon(circle.exterior)

# Convert coordinates to Point objects
def point(data):
    return Point(float(data['经度']), float(data['维度']))

# Count Luckin stores inside each Starbucks circle
def is_inside(data):
    polygon = data['Polygon']
    n = 0
    luckin_city = luckin[luckin['城市'] == data['城市']]
    for pt in luckin_city['Point']:
        if polygon.contains(pt):
            n += 1
    return n

starbucks['Polygon'] = starbucks.apply(circle, axis=1, args=(500,))
luckin['Point'] = luckin.apply(point, axis=1)
starbucks['Luckin_numbers'] = starbucks.apply(is_inside, axis=1)

Key findings include:

As of 2022, Starbucks has approximately 4,442 stores nationwide, while Luckin has about 3,904, a 14% difference.

Starbucks stores are concentrated in coastal first‑ and second‑tier cities (Yangtze River Delta, Pearl River Delta, Beijing‑Tianjin‑Hebei), whereas Luckin stores are more evenly spread, including many third‑ and fourth‑tier cities.

On average, each Starbucks store is surrounded by 0.6 Luckin stores within a 500 m radius; the maximum observed is 7 Luckin stores near a single Starbucks.

The city with the highest average number of nearby Luckin stores is Linyi, with 1.8 per Starbucks.

Heatmaps illustrate that Starbucks density is highest along the coast, while Luckin shows a more uniform distribution across inland regions.

In conclusion, the analysis reveals a strong spatial relationship between the two coffee chains: Luckin often locates near Starbucks, leveraging the existing coffee‑drinking traffic to expand rapidly.

About this article

For questions about attribution, corrections or content rights, please contactadmin@besthub.devand we will review it promptly.

Report an issue with this article
big dataPythongeospatial analysisStore Distribution

Reader feedback

Was this useful?

Useful0

Discussion 0

Questions, practical examples and thoughtful responses.

Open full discussion