API key
### Google Maps API Key
register_google(key='')
# 경도와 위도로 표시할 중심 좌표
center_lon_lat <- c(127.385, 36.375)
# 지도 다운로드
krMap <- get_googlemap(center_lon_lat, zoom = 12)
ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=terrain&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=terrain&key=xxx]8;;>
# 지도 표시
ggmap(krMap)

# 지도 다운로드
krMap <- get_googlemap(center_lon_lat, zoom = 12, maptype = "roadmap")
ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=roadmap&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=roadmap&key=xxx]8;;>
# 지도 표시
ggmap(krMap)

공공데이터포털
- 소상공인시장진흥공단_상가(상권)정보_대전_202403.csv
### Data
store.file <- "./data/소상공인시장진흥공단_상가(상권)정보_대전_202403.csv"
data.store <- read.csv(store.file, header=T, fileEncoding = "UTF-8")
data.store %>% head()
### 자료 추출 - 커피전문점
data.cafe <- data.store %>% subset(상권업종소분류명=="카페")
### 산점도 – ggplot()
ggplot() + geom_point(data=data.cafe, aes(x=경도, y=위도, colour=시군구명))

# 지도 다운로드
krMap <- get_googlemap(center_lon_lat, zoom = 12, maptype = "roadmap")
ℹ <]8;;https://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=roadmap&key=xxxhttps://maps.googleapis.com/maps/api/staticmap?center=36.375,127.385&zoom=12&size=640x640&scale=2&maptype=roadmap&key=xxx]8;;>
### 지도 표시
ggmap(krMap) + geom_point(data=data.cafe, aes(x=경도, y=위도, colour=시군구명))
경고: Removed 48 rows containing missing values or values outside the scale range (`geom_point()`).

### 등고선
ggmap(krMap) + stat_density2d(data=data.cafe, aes(x=경도, y=위도))
경고: Removed 48 rows containing non-finite outside the scale range (`stat_density2d()`).

### 밀도
ggmap(krMap) +
stat_density2d(data=data.cafe, aes(x=경도, y=위도), geom="polygon", alpha=0.2)
경고: Removed 48 rows containing non-finite outside the scale range (`stat_density2d()`).

### 밀도 + 색상
ggmap(krMap) +
stat_density2d(data=data.cafe,
aes(x=경도, y=위도, fill=after_stat(level)),
geom="polygon", alpha=0.2) +
scale_fill_gradient(low="yellow", high="red")
경고: Removed 48 rows containing non-finite outside the scale range (`stat_density2d()`).
