해결된 질문
작성
·
37
0
카페 주소 6개를 지오코딩 데이터로 변환하여
이 데이터와 카페들의 커피 가격 데이터(data frame)를 결합하여
지도로 만들어 보려 했는데 마지막 단계에서 아래와 같은 에러가 뜹니다.
[.data.table`(dt, , c(tml$popup.vars, "tmapID__"), with = FALSE)에서 다음과 같은 에러가 발생했습니다:
column(s) not found: [geometry]
어디에서 문제가 생긴 것일지 팁을 좀 알려주실 수 있으신지요?
제가 사용한 코드는 아래와 같습니다:
#파일 객체 생성
cafe <- readOGR(dsn = "C:/DataScience/geo_coding", layer = "a")
price <- read_excel("C:/DataScience/cafe_price.xlsx")
#카페 지오코딩 파일(cafe)에 중복 데이터가 없는지 확인
any(duplicated(cafe$field1))
#카페 가격 파일(price)에 중복 데이터가 없는지 확인
any(duplicated(price$cafe_name))
#가격 파일의 카페명(cafe_name)과 지오코딩 파일의 field1 동일여부 확인
all(price$cafe %in% cafe$field1)
#지오코딩 파일의 field1과 가격 파일의 카페명(cafe_name) 동일여부 확인
all(cafe$field1 %in% price$cafe)
library(sp)
install.packages('tmap')
library(tmap)
# cafe와 price 합치기
cafe_merge<-merge(cafe,price, by.x="field1", by.y="cafe")
# Choropleth with col mapped to estimate
tm_shape(cafe_merge) +
tm_fill(col = "Americano") #Americano는 아메리카노 가격 변수명
(참고로 지오코딩 데이터는 지오서비스라는 사이트(https://www.geoservice.co.kr/)에서 제가 작성한 주소 엑셀 파일을 변환시킨 것이고 해당 사이트에서는 변환한 내용이 지도에 잘 뜨지만
R로 불러와 plot( )을 실행하지도 화면이 뜨지 않고 흰 백지에 해당 카페의 지점만 +로 6개가 표시되었습니다)
답변