-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
46 lines (37 loc) · 1.38 KB
/
test2.py
File metadata and controls
46 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import geopandas as gpd
import matplotlib.pyplot as plt
import json
# -------------------------------
# 1. 데이터 로드
# -------------------------------
# 포항 경계 (투영 좌표계 EPSG:4326)
g_boundary_4326 = gpd.read_file("./data/pohang_boundary_4326.geojson")
# 64km × 64km 1km 격자
grid_gdf = gpd.read_file("./data/pohang_grid_64km_1km_cells_4326.geojson")
# 🔥 fire_cells.json 불러오기
with open("/Users/juseungl/Documents/deflame/fire_cells.json", "r", encoding="utf-8") as f:
fire_cells = json.load(f)
# -------------------------------
# 2. row, col → grid index 매핑
# -------------------------------
# row, col 추출
fire_indices = []
for cell in fire_cells:
r, c = cell["row"], cell["col"]
idx = grid_gdf.index[(grid_gdf["row"] == r) & (grid_gdf["col"] == c)]
if not idx.empty:
fire_indices.append(idx[0])
# -------------------------------
# 3. 시각화
# -------------------------------
fig, ax = plt.subplots(figsize=(8, 8))
# 1) 기본 격자 (회색)
grid_gdf.boundary.plot(ax=ax, color="lightgray", linewidth=0.5)
# 2) 불난 셀 색칠 (빨간색)
grid_gdf.loc[fire_indices].plot(ax=ax, color="red", alpha=0.6, edgecolor="black")
# 3) 포항 경계선
g_boundary_4326.plot(ax=ax, color="none", edgecolor="blue", linewidth=2)
ax.set_title("Pohang GeoJSON")
ax.set_xlabel("EPSG:4326 Longitude")
ax.set_ylabel("EPSG:4326 Latitude")
plt.show()