X軸(Standardized Variable):表示各村里速食店密度的標準化值。也就是某一村里速食店密度與全市平均值的差異經過標準化處理後的結果,數值正表示高密度、負則為低密度。
Y軸(Standardized Lagged Variable):表示某村里鄰近村里的速食店密度的空間鄰近平均值(也經標準化),即空間延遲變數。這代表了該地點周邊地區的速食店密度狀況。
空間型態(Spatial Pattern):由圖中可以看出,大多數點集中在第一象限(高-高)與第三象限(低-低),表示速食店密度有明顯的空間群聚現象(spatial clustering)。也就是速食店密度高的村里,其周邊村里也 tend to 高密度;反之亦然,顯示出正向空間自相關。
趨勢線的斜率即為 全球Moran’s I統計值(Global Moran’s I)。在本圖中:
斜率 = 0.982 表示該城市速食店密度呈現高度的正向空間自相關(high positive spatial autocorrelation)。
換言之,速食店密度在空間上並非隨機分布,而是有顯著的聚集趨勢。
趨勢線越接近1,表示空間上的類似性越強。0.982 非常接近1,表示大多數村里的速食店密度與其鄰近村里的密度非常類似。
大於 0、等於 0 或小於 0,並說明判斷的理由。(3 分,理由正確才會給分)
答案:Local Moran’s I 統計量在不同地點 可能會大於0、等於0或小於0。
理由:
大於 0:表示該區域與鄰近區域有相似的值(如高-高或低-低),即為空間群聚。
小於 0:表示該區域與鄰近區域有相反的值(如高-低或低-高),即為空間離異(Spatial Outlier)。
等於 0:表示該區域的值與鄰近區域的值之間無顯著的空間關聯,即為隨機分布。
因此,即使整體 Moran’s I 很高(如 0.982),但在 Local Moran’s I 的分析中,每個地點仍可能出現不同的空間關聯型態,這是區域性空間分析的重要價值。
資料來源:https://wenlab501.github.io/GEOG2017/DATA/
rm(list = ls())
library(sf)
library(dplyr)
setwd("C:/空間分析")
fastfood <- st_read("Tpe_Fastfood/Tpe_Fastfood.shp",options="ENCODING=BIG5")
schools <- st_read("SCHOOL/SCHOOL.shp",options="ENCODING=BIG5")
villages <- st_read("Taipei_Vill/Taipei_Vill.shp",options="ENCODING=BIG5")
villages <- villages %>%
mutate(group = case_when(
TOWN %in% c("文山區", "大安區", "中正區") ~ "A",
TOWN %in% c("信義區", "南港區", "松山區") ~ "B",
TRUE ~ NA_character_
))
# 1. 建立緩衝區並加上 store_id
fastfood_buffer <- fastfood %>%
mutate(store_id = row_number()) %>%
st_buffer(dist = 1000)
# 2. 空間 join 速食店 buffer 與學校
joined <- st_join(fastfood_buffer, schools, join = st_intersects)
# 3. 計算每家速食店涵蓋的學校數
school_count <- joined %>%
st_drop_geometry() %>%
group_by(store_id) %>%
summarise(n_school = n())
# 4. 將行政區加入速食店點位
fastfood_with_area <- st_join(fastfood, villages["group"]) %>%
mutate(store_id = row_number())
# 5. 合併學校數資訊
analysis_data <- left_join(fastfood_with_area, school_count, by = "store_id") %>%
filter(!is.na(group))
t.test(n_school ~ group, data = analysis_data, var.equal = FALSE)
t 值:1.5977 自由度:df = 51 p 值:0.1163 95% 信賴區間:[–0.1418, 1.2474] 平均值(學校數): A 區:3.871 B 區:3.318
由於 p 值 = 0.1163 > 顯著水準 α = 0.05,故無法拒絕虛無假設,代表 A 區與 B 區速食店在 1 公里內涵蓋的學校數量之間無顯著差異。
雖然 A 區的平均數略高(3.87 vs. 3.32),但統計上並未達到顯著水準,表示這樣的差異可能來自於樣本波動而非真實差異。
library(sf)
library(spdep)
library(dplyr)
# 假設 fastfood_wgs 已經轉換為 EPSG:4326,再轉回 TM2 投影建立格網(以公尺為單位)
tm2_crs <- st_crs(3826)
fastfood_tm2 <- st_transform(fastfood, crs = tm2_crs)
# 建立邊界範圍(例如從村里邊界來建網格)
study_area <- st_union(st_transform(villages, crs = tm2_crs))
# 建立 500 公尺方格
grid <- st_make_grid(study_area, cellsize = 500, square = TRUE) %>%
st_sf(grid_id = 1:length(.), geometry = .)
# 統計每格內速食店數量
grid$fastfood_count <- lengths(st_intersects(grid, fastfood_tm2))
# 建立鄰接關係(Queen’s contiguity)
nb <- poly2nb(grid, queen = TRUE)
lw <- nb2listw(nb, style = "W") # 權重矩陣
# 計算 correlogram(全距距離下的 Moran's I)
correlog <- sp.correlogram(nb, grid$fastfood_count, order = 10, method = "I", style = "W", zero.policy = TRUE)
# 繪圖
plot(correlog)
根據圖形(見下圖),Moran’s I 值呈現以下趨勢:
第 1 階鄰近距離(lag = 1):
Moran’s I 約為 0.21,代表具有顯著正向空間自相關,即速食店數量在第一階鄰近單元間呈現聚集性分布。
隨著鄰近階數增加(lag 2 ~ lag 10):
Moran’s I 值逐漸下降,至第 7–10 階後趨近於 0,且部分區間誤差線穿越 0,表示在更遠距離下無顯著空間自相關。
從結果可知,速食店在500 公尺至 1500 公尺範圍內具有明顯的空間聚集效應,表示此範圍內的商業據點或生活機能可能對速食店分布產生空間吸引效果。
空間影響範圍推論:速食店的空間影響主要集中在前 2~3 階鄰近範圍內(約 1–1.5 公里)。
空間規劃意涵:在規劃都市商業分布或健康飲食環境政策時,可考量速食店於鄰近範圍聚集性所產生的影響,並可針對聚集區域進行後續營養政策或學校周邊食品環境調查。
結論總結: 本分析以 500 公尺空間格網為單位,計算速食店空間自相關情形。結果顯示在 1.5 公里以內存在明顯的空間群聚,反映速食店選址可能受到商圈或人口密度等地理因素影響。超過此距離則空間影響逐漸減弱,呈現空間獨立趨勢。
library(sf)
library(ggplot2)
library(dplyr)
# 將速食店與行政邊界都轉為 EPSG:3826(TWD97 / TM2)
villages_tm2 <- st_transform(villages, crs = 3826)
fastfood_tm2 <- st_transform(fastfood, crs = 3826)
# 建立涵蓋村里範圍的 500 公尺格網
grid <- st_make_grid(villages_tm2, cellsize = 500, square = TRUE)
grid_sf <- st_sf(grid_id = 1:length(grid), geometry = grid)
# 使用 st_intersects 判斷速食店點是否落在格子內
grid_sf$fastfood_count <- lengths(st_intersects(grid_sf, fastfood_tm2))
library(ggplot2)
library(viridis)
ggplot() +
geom_sf(data = grid_sf, aes(fill = fastfood_count), color = NA) +
scale_fill_viridis_c(option = "inferno", name = "速食店數量", direction = -1) +
geom_sf(data = villages_tm2, fill = NA, color = "black", linewidth = 0.3) +
labs(
title = "500 公尺格網中的速食店分布熱度圖",
caption = "資料來源:Tpe_Fastfood & Taipei_Vill"
) +
theme_minimal() +
theme(
plot.title = element_text(size = 16, face = "bold"),
legend.position = "right"
)
台北市中部與西南部地區(如中正區、西門町、大安區、信義計畫區)出現多個深色格網,顯示速食店密集分布、明顯聚集。 此現象與高密度商業活動、人流匯集與交通節點高度重疊,符合商業選址邏輯。
北投區、文山區、南港區、內湖區等周邊區域,大多格網顯示為淺色(0–1 間),代表速食店較為稀疏或零星分布。 此與住宅比例較高、交通較不便或非主要商圈有關。
高密度區域集中在幾個中心點,其他地區呈現廣泛的低密度格網,顯示空間異質性強、非隨機分布。
此熱度圖明確展現速食店在台北市的分布呈現典型的都市核心聚集模式。商業活動發達區域內(如信義商圈、台北車站周邊)格網中可達 3–4 間速食店,反映該區域具有:
而其他非核心區域則較難吸引密集開設,呈現出「都市核心—邊緣擴散」的空間分布態勢。
# 統計每格內的學校數量
school_tm2 <- st_transform(schools, crs = 3826)
grid_sf$school_count <- lengths(st_intersects(grid_sf, school_tm2))
library(spdep)
nb <- poly2nb(grid_sf, queen = TRUE) # 鄰接矩陣
lw <- nb2listw(nb, style = "B", zero.policy = TRUE) # B = binary weights
# 計算 Gi* 統計量
gi_fastfood <- localG(grid_sf$fastfood_count, listw = lw, zero.policy = TRUE)
gi_school <- localG(grid_sf$school_count, listw = lw, zero.policy = TRUE)
# 加入到格網屬性
grid_sf$gi_fastfood <- as.numeric(gi_fastfood)
grid_sf$gi_school <- as.numeric(gi_school)
# 計算 p 值(由 Z 分數轉換)
grid_sf$p_fastfood <- 2 * pnorm(-abs(grid_sf$gi_fastfood))
grid_sf$p_school <- 2 * pnorm(-abs(grid_sf$gi_school))
# 多重檢定修正(Bonferroni 或 FDR)
grid_sf$fastfood_sig <- p.adjust(grid_sf$p_fastfood, method = "fdr") < 0.05
grid_sf$school_sig <- p.adjust(grid_sf$p_school, method = "fdr") < 0.05
library(ggplot2)
# 熱區圖:速食店 Gi*
ggplot(grid_sf %>% filter(fastfood_sig)) +
geom_sf(aes(fill = gi_fastfood), color = NA) +
scale_fill_gradient2(low = "blue", mid = "white", high = "red",
midpoint = 0, name = "Gi* Z 分數") +
labs(title = "速食店熱區(Gi*,FDR 修正 p < 0.05)") +
theme_minimal()
# 熱區圖:學校 Gi*
ggplot(grid_sf %>% filter(school_sig)) +
geom_sf(aes(fill = gi_school), color = NA) +
scale_fill_gradient2(low = "blue", mid = "white", high = "red",
midpoint = 0, name = "Gi* Z 分數") +
labs(title = "學校熱區(Gi*,FDR 修正 p < 0.05)") +
theme_minimal()
分布特徵:
主要集中在 台北市中南部(中正、大安、信義交界區域),出現多個 Z 分數 > 10 的高顯著熱區,最亮紅格網 Z 值甚至高達 15,顯示此區域速食店密度顯著高於鄰近格網。
其他區域(如北投、內湖)則無明顯熱區,顯示分布不均。
空間涵義:
該熱點區域應為重要商業中心、交通轉運站或學生聚集地,速食店高度集中,形成統計顯著的熱區。
分布特徵:
熱區主要位於 文山、信義與萬華交界處,Z 分數介於 4 至 8,顯著程度略低於速食店熱區,但也形成明顯聚集。
南區及市中心仍有少數熱區,但北部格網幾乎皆為非顯著值。
空間涵義:
學校熱區與速食店熱區部分重疊,可能形成「食品可及性過高」區域(如學校旁速食選項集中),對青少年的健康行為有潛在影響。
熱區集中區域:中正-大安-信義交界 Z 值最高:≈ 15
熱區範圍:密集且連續 解釋:與商圈、高人流區高度重疊
熱區集中區域:文山-萬華與信義、部分南區
Z 值最高:≈ 8
熱區範圍:分布較分散
解釋:與住宅區或教育區有關
二者熱區部分重疊(尤其在中南部地區),但速食店的聚集程度明顯更集中且顯著。 學校熱區較廣但分布較為碎片化,反映其規劃與行政區邊界、人口結構關係較密切。
library(spatstat)
library(sf)
library(dplyr)
# Step 1:轉換為 TWD97 TM2 座標
schools_tm2 <- st_transform(schools, crs = 3826)
fastfood_tm2 <- st_transform(fastfood, crs = 3826)
villages_tm2 <- st_transform(villages, crs = 3826)
# Step 2:建立 study area(owin 格式)
boundary <- st_union(st_geometry(villages_tm2))
window <- as.owin(st_as_sf(boundary))
# Step 3:將學校加上行政區欄位
schools_with_zone <- st_join(schools_tm2, villages_tm2[, c("TOWN", "VILLAGE")])
# Step 4:定義行政區
zones <- c("大安區", "文山區", "信義區")
# Step 5:建立速食店的 ppp 格式
coords_fastfood <- st_coordinates(fastfood_tm2)[, 1:2]
fastfood_ppp <- as.ppp(coords_fastfood, W = window)
# Step 6:依行政區計算 F(d)
par(mfrow = c(1, 3)) # 三張圖排一列
for (zone in zones) {
schools_zone <- schools_with_zone %>% filter(TOWN == zone)
coords_zone <- st_coordinates(schools_zone)[, 1:2]
school_ppp <- as.ppp(coords_zone, W = window)
# 計算 F(d)
Fd <- Fest(school_ppp, fastfood_ppp)
# 繪圖
plot(Fd, main = paste("F(d) 累積函數 -", zone), lwd = 2)
}
本題參考 Transportation Research Part A, 45 (2011) 所提出之 F(d) 累積距離分布函數 方法,透過點模式分析(Point Pattern Analysis)計算:
每所學校距離最近一間速食店的距離分布
三種估計方法:km (Kaplan–Meier)、bord (border correction)、cs (translation correction)
並與 pois(r)(完全隨機分布)比較
累積曲線 F(d) 上升愈快,表示學校越早、越容易接近速食店,代表周邊速食店分布越密集。
F(d) 曲線快速上升,尤其在 1000–2500 公尺內的斜率高。
表示大安區學校附近速食店分布密度高、鄰近性強。
實測 F(d) 曲線(黑線)明顯早於隨機分布(藍虛線),顯示有聚集性而非隨機。
F(d) 曲線相對平緩,曲線在 3000 公尺後才有顯著上升。
表示學校與速食店距離普遍較遠,鄰近性較差,速食店分布較稀疏。
曲線與 F_pois(r) 接近,顯示速食店可能接近隨機分布。
F(d) 曲線上升介於大安與文山之間。
在 1500–3000 公尺內有適度上升,表示部分學校附近速食店分布密度尚可,但整體不如大安密集。
曲線略高於隨機分布,顯示略具聚集特性。
F(d)上升速度:快速,鄰近速食店密度:高度集中,空間特徵:非隨機聚集
#### 文山區
F(d)上升速度:緩慢,鄰近速食店密度:稀疏,空間特徵:近似隨機分布 ####
信義區
F(d)上升速度:中等,鄰近速食店密度:局部聚集,空間特徵:部分集中
library(ggplot2)
fd_list <- list()
for (zone in zones) {
schools_zone <- schools_with_zone %>% filter(TOWN == zone)
coords_zone <- st_coordinates(schools_zone)[, 1:2]
school_ppp <- as.ppp(coords_zone, W = window)
Fd <- Fest(school_ppp, fastfood_ppp)
fd_df <- data.frame(r = Fd$r, F = Fd$km, 區域 = zone)
fd_list[[zone]] <- fd_df
}
# 合併為一張表
fd_all <- bind_rows(fd_list)
# 畫出比較圖
ggplot(fd_all, aes(x = r, y = F, color = 區域)) +
geom_line(size = 1.2) +
labs(title = "三區學校到速食店的 F(d) 比較",
x = "距離 d(公尺)", y = "F(d) 累積機率") +
theme_minimal()
# 計算 K(3000) 與 L(3000)
K_result <- Kest(fastfood_ppp, correction = "border")
L_result <- Lest(fastfood_ppp, correction = "border")
# 繪製 L(d) 曲線(含 95% 信賴區間)
envelope_L <- envelope(fastfood_ppp, Lest, nsim = 999, correction = "border", savefuns = TRUE)
plot(envelope_L, main = "L(d) + 95% 信賴區間 (速食店)", legend = FALSE)
# 取得 L(3000) 的數值與信賴區間
L_value <- with(L_result, Lhat[which(r == 3000)])
L_ci_lower <- with(envelope_L, lo[which(r == 3000)])
L_ci_upper <- with(envelope_L, hi[which(r == 3000)])
cat("L(3000) =", L_value, "\n95% CI =", L_ci_lower, "~", L_ci_upper, "\n")
黑色實線代表實際觀測的 L(d) 值
灰色陰影區表示 95% 信賴區間(Monte Carlo 模擬)
虛線為理論線(期望隨機分布)
在 d = 3000 公尺前後,實際 L(d) 曲線明顯高於信賴區間上緣。
顯示速食店在此範圍內的空間分布非隨機,而是呈現顯著聚集現象。
隨距離增加(超過 4000m)後,L(d) 開始趨近於信賴區間,聚集效應趨緩。
# 加入 school_type 變項,"公立"/"私立"
schools_with_type <- schools_with_zone %>% filter(!is.na(Type)) # 確保欄位存在
# 分別轉換為 ppp 格式
coords_public <- st_coordinates(schools_with_type %>% filter(Type == "公立"))
coords_private <- st_coordinates(schools_with_type %>% filter(Type == "私立"))
public_ppp <- as.ppp(coords_public, W = window)
private_ppp <- as.ppp(coords_private, W = window)
# Bivariate F function:私立學校到速食店
Fd_private <- Fest(private_ppp, fastfood_ppp)
plot(Fd_private, main = "F(d) - 私立學校到速食店")
# Bivariate F function:公立學校到速食店
Fd_public <- Fest(public_ppp, fastfood_ppp)
plot(Fd_public, main = "F(d) - 公立學校到速食店")
F(d) 曲線(黑線、紅虛線、綠點線)在 0–1500 公尺內即快速上升,整體曲線靠近 F_pois(r),顯示分布密度偏高。
多數私立學校在1500 公尺內就能接近速食店,顯示私校多設於商業或交通便利區。
F(d) 曲線上升速度較慢,距離延伸至 2500–3000 公尺才逐漸趨近飽和。
表示許多公立學校分布在距速食店較遠的位置,速食店分布較分散或可及性較低。
F(d)上升速度較快,平均可及距離較近(<1500m),空間分布特徵:聚集、高密度,與速食店接近程度 明顯較高
F(d)上升速度較慢,平均可及距離較遠(>2000m),空間分布特徵:分散、較隨機,與速食店接近程度相對較低
分析健康餐盒店面數量及位置,因為有可能是周遭提供的食物造成無法達成健康生活,速食的方便性以及在台北相對是便宜的選擇。
healthy <- st_read("healthy_restaurants.geojson") # 健康餐盒店
# 3. 統一投影(使用 TWD97 / TM2)
schools_tm2 <- st_transform(schools, crs = 3826)
healthy_tm2 <- st_transform(healthy, crs = 3826)
villages_tm2 <- st_transform(villages, crs = 3826)
# 4. 建立 500 公尺緩衝區,計算每個學校周邊健康餐廳數量
school_buffer <- st_buffer(schools_tm2, dist = 500)
school_buffer$healthy_count <- lengths(st_intersects(school_buffer, healthy_tm2))
# 5. 合併行政區欄位資訊
schools_with_vill <- st_join(school_buffer, villages_tm2["TOWN"])
# 6. 各行政區平均健康餐盒店數統計(可選做)
school_summary <- schools_with_vill %>%
st_drop_geometry() %>%
group_by(TOWN) %>%
summarise(avg_healthy = mean(healthy_count, na.rm = TRUE))
# 7. 製圖:健康餐廳可及性 choropleth 圖
tm_shape(villages_tm2) +
tm_polygons() +
tm_shape(schools_with_vill) +
tm_symbols(
col = "healthy_count",
style = "fixed",
breaks = c(0, 1, 2, 3, 5), # 手動分級:0~1, 1~2, 2~3, 3~5
labels = c("0 間", "1 間", "2 間", "3 間以上"),
palette = "YlOrBr",
size = 0.25,
title.col = "500公尺內健康餐盒數"
) +
tm_layout(
title = "臺北市學校周邊 500 公尺內健康餐盒可及性分布",
legend.outside = TRUE
)
# 建立 500 公尺格網
study_area <- st_union(villages_tm2)
grid <- st_make_grid(study_area, cellsize = 500, square = TRUE) %>%
st_sf(grid_id = 1:length(.), geometry = .)
# 計算每格內速食與健康餐盒店數
grid$fastfood_count <- lengths(st_intersects(grid, fastfood_tm2))
grid$healthy_count <- lengths(st_intersects(grid, healthy_tm2))
# 空間分布對照圖:速食 + 健康餐盒
tmap_mode("plot") # ✅ Notebook 建議 plot 模式
# 建立格網中心點作為健康餐盒點圖層
grid_centers <- st_centroid(grid)
tm_shape(grid) +
tm_polygons(
col = "fastfood_count",
palette = "Reds", # ✅ 明確指定紅色
title = "速食店數"
) +
tm_shape(grid_centers) +
tm_bubbles(
col = "healthy_count",
palette = "Greens", # ✅ 明確指定綠色
size = 0.3,
title.col = "健康餐盒數"
) +
tm_shape(villages_tm2) +
tm_borders(col = "black", lwd = 0.3) +
tm_layout(
main.title = "臺北市速食與健康餐盒分布對照(含行政界)",
legend.outside = TRUE
)
# 自訂分類標準:1 間以上(含)為高,0為低
grid$type <- with(grid, case_when(
healthy_count >= 1 & fastfood_count >= 1 ~ "雙高區",
healthy_count >= 1 & fastfood_count < 1 ~ "健康多速食少區",
healthy_count < 1 & fastfood_count >= 1 ~ "速食多健康少區",
healthy_count < 1 & fastfood_count < 1 ~ "雙低區",
TRUE ~ "資料缺失"
))
library(tmap)
tmap_mode("plot")
tm_shape(grid) +
tm_polygons(
col = "type",
palette = c(
"雙高區" = "dodgerblue",
"健康多速食少區" = "forestgreen",
"速食多健康少區" = "darkorange",
"雙低區" = "lightgray"
),
title = "速食與健康餐盒分類"
) +
tm_shape(villages_tm2) +
tm_borders(col = "black", lwd = 0.3) +
tm_layout(
main.title = "臺北市格網中速食與健康餐盒供應分類地圖(1 間為界)",
legend.outside = TRUE
)
o 如中正區、信義區、松山區一帶,店家資源豐富、需求量高。 o 顯示這些地區學生與上班族的複合需求共同帶動餐飲市場的多樣供應。
o 在部分住宅區或學校旁邊,有明顯的速食偏好現象。 o 顯示健康選項尚未普及,潛在營養失衡風險區。
o 通常出現在邊緣社區或特定健康飲食倡議地點。 o 未來可成為推動「健康導向商圈」之重點區塊。
o 餐飲設施稀少,表示潛在市場不足或可接納行動餐車、補助政策。
# 轉換為座標矩陣
coords_healthy <- st_coordinates(healthy_tm2)[, 1:2]
coords_fastfood <- st_coordinates(fastfood_tm2)[, 1:2]
# 建立帶有 marks 的 data.frame
marks_healthy <- data.frame(x = coords_healthy[, 1],
y = coords_healthy[, 2],
type = "healthy")
marks_fastfood <- data.frame(x = coords_fastfood[, 1],
y = coords_fastfood[, 2],
type = "fastfood")
# 合併兩者
marks_all <- rbind(marks_healthy, marks_fastfood)
# 建立 ppp 格式,需指定 window
all_ppp <- ppp(x = marks_all$x,
y = marks_all$y,
window = window,
marks = as.factor(marks_all$type))
Lcross(all_ppp, i = "healthy", j = "fastfood")
plot(Lcross(all_ppp, i = "healthy", j = "fastfood", correction = "border"),
main = "Cross-L Function: 健康餐盒到速食店的空間關係",
xlab = "距離 r(公尺)", ylab = expression(L[ij](r)))
abline(0, 1, col = "gray") # 理論線 L(r) = r
黑線為觀察值(border 校正),紅虛線為隨機期望下的 L(r)。
結果顯示:整體 L(r) 曲線顯著高於理論線,表示健康餐盒店周圍有較多速食店,呈現顯著的空間群聚關係。
推論:兩類型的店家可能會集中於相同區域,如商圈、大學城或交通便利處。
envelope_cross <- envelope(all_ppp, fun = Lcross,
i = "healthy", j = "fastfood",
nsim = 999, correction = "border",
savefuns = TRUE)
plot(envelope_cross,
main = "Cross-L Function Envelope(健康→速食)",
xlab = "距離 r(公尺)", ylab = expression(L[ij](r)))
abline(0, 1, col = "gray")
黑線:實際觀察值;灰帶:95% 信賴區間;紅線:理論值。
實際觀察值大部分都落在信賴區間上方,尤其在距離 500–3500 公尺範圍內偏高。
結論:在此距離範圍內,健康餐盒店與速食店存在比隨機分布更強的空間依附現象,代表兩者傾向選址於相近區域。
# 指派 grid 為 grid_sf
grid <- grid_sf
grid_sf <- st_join(grid_sf, school_buffer["healthy_count"])
# 先建立是否鄰近學校的分類欄位
grid_sf$near_school <- ifelse(grid_sf$school_count > 0, "校園周邊", "非校園區")
# t 檢定:速食
t_fastfood <- t.test(fastfood_count ~ near_school, data = grid_sf)
# t 檢定:健康餐盒
t_healthy <- t.test(healthy_count ~ near_school, data = grid_sf)
print(t_fastfood)
Welch Two Sample t-test
data: fastfood_count by near_school
t = -5.8629, df = 381.8, p-value = 9.849e-09
alternative hypothesis: true difference in means between group 非校園區 and group 校園周邊 is not equal to 0
95 percent confidence interval:
-0.2125445 -0.1057882
sample estimates:
mean in group 非校園區 mean in group 校園周邊
0.06083365 0.22000000
print(t_healthy)
Welch Two Sample t-test
data: healthy_count by near_school
t = -0.27881, df = 643.35, p-value = 0.7805
alternative hypothesis: true difference in means between group 非校園區 and group 校園周邊 is not equal to 0
95 percent confidence interval:
-0.08851050 0.06650141
sample estimates:
mean in group 非校園區 mean in group 校園周邊
0.3604240 0.3714286
為探討校園周邊與非校園區在健康飲食供給上的空間分布差異,本研究針對格網內的速食店與健康餐盒店數進行了獨立樣本 t 檢定,檢視不同區域類型之平均供給情形,結果如下:
根據 Welch Two Sample t-test 結果:
t 值 = -5.8629,p 值 < 0.001(p = 9.849e-09),顯示速食店數量在「校園周邊」與「非校園區」之間具有顯著差異。
平均值比較:
校園周邊:0.22 間/格
非校園區:0.06 間/格
95% 信賴區間:差異範圍在 [-0.21, -0.11],意即「校園周邊」的速食供給密度顯著高於其他區域。
此結果顯示校園周邊存在速食業者明顯聚集的現象,可能與學生族群的高需求、可預期消費行為及區域內高密度商業活動有關。此空間集中可能加劇青少年對高熱量食物的可近性,對健康飲食介入政策形成挑戰。
根據 t 檢定結果:
t 值 = -0.2788,p 值 = 0.7805(不顯著)
平均值比較:
校園周邊:0.37 間/格
非校園區:0.36 間/格
95% 信賴區間:[-0.0885, 0.0665],包含 0,表示無顯著差異。
雖然健康餐盒店在校園周邊格數稍多,但整體而言分布並未顯著偏向學校區域,顯示此類飲食選擇尚未如速食業者般強烈聚集於特定需求區塊。此結果亦反映目前「健康飲食供給」策略的區位選擇可能尚未精準聚焦於學生可及性或缺乏誘因集聚於學校周邊。
資料整合與前處理
收集臺北市速食店、健康餐盒店與學校位置資料(點資料);
匯入臺北市行政區邊界與建立 500m 分割格網;
建立學校 500 公尺緩衝區(school buffer)以劃分「校園周邊」與「非校園區」。
空間統計與可視化
計算每格的速食店與健康餐盒店數量;
進行熱點分析(Gi*)與空間聚集檢定(K/L 函數);
繪製空間分布圖,包含行政區界線與緩衝區,區分不同店家密度區塊。
統計檢定與類別劃分
將格網依據速食與健康店家數量進行類別劃分(雙高、雙低、高低、低高);
進行 t 檢定比較校園周邊與非校園區之間店家數是否存在顯著差異。
速食店:校園周邊格子平均速食店數顯著高於非校園區(p < 0.001)。
健康餐盒店:雖校園周邊的健康餐盒店略多,但差異不顯著(p = 0.78)。
以每格兩間以上店家定義「高」,發現「雙高」區塊集中於商圈與學校匯聚區;
「健康高、速食低」的格子稀少,顯示健康選項常與速食並存,而非單獨出現。
雖校園周邊已有較多健康餐盒店,但未顯著高於其他區域,應進一步透過政策補助或租金減免鼓勵健康選項設點。
可依據「雙高」與「速食高健康低」區塊進行飲食環境評估,進一步導入健康飲食教育與分級管理制度。
善用學校周邊既有的商業聚集力道,引導在地小商家納入健康餐供應鏈條,建構「校園-商圈-健康餐」三角互動機制。
建議持續透過 GIS 建立「校園周邊健康環境監測平台」,定期評估店家數變動與熱點轉移,以利未來公共健康政策制定與成效追蹤。