>RE::VISION CRM

R 데이터 분석

실거래가 분석

YONG_X 2015. 7. 13. 09:46

 

부동산실거래가 분석용 샘플

 

201506매매아파트.xls

 

#------------------

# 지도위에 색칠 참고

#-------------------------

 


library(RgoogleMaps)
#
http://data-sci.tistory.com/6

dlat <- c(37.2733038, 37, 37.45)
dlong <- c(127.0722408, 127.02, 127.06)
dlab <- c("home", "office", "buyer")

map_info <- data.frame(dlat, dlong, dlab)
names(map_info) <- c( "latitude", "longitude", "label")

map.center <- c(37.4, 127)
zoom.level <-11
mymap <- GetMap(center = map.center, zoom = zoom.level, maptype = "terrain", format = "png32")
PlotOnStaticMap(mymap, lat = map_info$latitude, lon = map_info$longitude,  destfile = "mymap.point.png", cex = 1.5, pch =19, col="red")

# or alternatively ... poin labels

TextOnStaticMap(mymap, lat = map_info$latitude, lon = map_info$longitude, labels=map_info$label, cex=0.8, col = 'blue')


#--------------

dlat <- c(37.27, 37.273, 37.274)
dlong <- c(127.087, 127.06, 127.08)
dlab <- c("home", "office", "buyer")

map_info <- data.frame(dlat, dlong, dlab)
names(map_info) <- c( "latitude", "longitude", "label")

map.center <- c(37.27, 127.078)
zoom.level <-15
mymap <- GetMap(center = map.center, zoom = zoom.level, maptype = "terrain", format = "png32")
PlotOnStaticMap(mymap, lat = map_info$latitude, lon = map_info$longitude,  destfile = "mymap.point.png", cex = 1.5, pch =19, col="red")

# TextOnStaticMap(mymap, lat = map_info$latitude+0.01, lon = map_info$longitude, labels=map_info$label, cex=0.8, col = 'blue')

#-----------

dlat <- c(37.2667, 37.2663, 37.2662 )
dlong <- c(127.082, 127.0823, 127.0827 )
dlab <- c("home", "office", "bench")

map_info <- data.frame(dlat, dlong, dlab)
names(map_info) <- c( "latitude", "longitude", "label")

map.center <- c(37.265, 127.0823)
zoom.level <-17
mymap <- GetMap(center = map.center, zoom = zoom.level, maptype = "roadmap", format = "png32")
# mymap <- GetMap(center = map.center, zoom = zoom.level, maptype = "terrain", format = "png32")

# 점마다의 중요도와 의미에 따라 색상과 크기 조절 가능 (df에 미리 저장해 사용 )

PlotOnStaticMap(mymap, lat = map_info$latitude, lon = map_info$longitude,  destfile = "mymap.point.png", cex = 2, pch =10, col="red")



 

#====================

 

library(sp) # sp 라이브러리 로드

# http://www.gadm.org/download 에서 country와 level(0, 1, 2 중) 선택해서 다운로드 필요

print(load("KOR_adm1.RData")) # 데이터 로딩
[1] "gadm"

# 테스트용으로 지역의 랜덤값 추출
# language <- rep(seq(1,4),4)

# gadm$language <- as.factor(language)

names(gadm)

gadm$NAME_1

 [1] "Busan"             "Chungcheongbuk-do" "Chungcheongnam-do"
 [4] "Daegu"             "Daejeon"           "Gangwon-do"      
 [7] "Gwangju"           "Gyeonggi-do"       "Gyeongsangbuk-do"
[10] "Gyeongsangnam-do"  "Incheon"           "Jeju"            
[13] "Jeollabuk-do"      "Jeollanam-do"      "Seoul"           
[16] "Ulsan"           


yongfrq <- c(3, 1, 1, 1,   2, 2, 1, 5,   1, 1, 2, 3,   1, 1, 5, 1)
gadm$yongfrq <- as.factor(yongfrq)

# 컬러 선택
col = rainbow(length(levels(gadm$yongfrq)))
spplot(gadm, "yongfrq", col.regions=col, main="Provinces Yong  Visits")

#====================

# 경기도 색칠하기 예제

#===========================
require(sp)

print(load("KOR_adm2.RData"))

# gadm is a large scale polygonal data frame with 229

elements
# south Korea 전체 데이터 셋에서 경기도만으로 범위 한정
gadm_gg <- subset(gadm, NAME_1=='Gyeonggi-do' )

ranindex_value <- c(2,2,2,2,2,  2,2,2,2,2,  2,2,2,2,2,  2,2,2,2,2,   6,1,4,8,3,  2,2,2,2,2,  2)

gadm_gg$ranindexvar <- as.factor(ranindex_value)

# 컬러 선택 -- 레인보우 또는 블루퍼플

require(RColorBrewer)
col <- brewer.pal(8, "Reds")
spplot(gadm_gg, "ranindexvar", col.regions=col, main="Where I am in GG" )

# spplot(gadm_gg, "ranindexvar")


#========================

#  돈까쓰 ... 색칠하기

#--------------------------------------

 





#------------------------
# 예지관 :: , 127.036120
# 돈까쓰 :: 37.300944, 127.036311
# 커피 :: 37.300546, 127.037066

dlat <- c(37.300906, 37.300944, 37.300546 )
dlong <- c(127.036120, 127.036311, 127.037066 )
dlab <- c("교육장", "식당", "휴식처편의점")
dcol <- c("red", "blue", "grey")
dsize <- c(2,1,0.5 )

map_info <- data.frame(dlat, dlong, dlab, dcol, dsize)
names(map_info) <- c( "latitude", "longitude", "label",

"color", "pointsize")

#---------------
map.center <- c(37.300485,127.035833)
zoom.level <-17

mymap <- GetMap(center = map.center, zoom = zoom.level,

maptype = "roadmap", format = "png32")

# 점마다의 중요도와 의미에 따라 색상과 크기 조절 가능 (df

에 미리 저장해 사용 )

PlotOnStaticMap(mymap, lat = map_info$latitude, lon =

map_info$longitude,  destfile = "mymap.point.png", cex =

map_info$pointsize, pch =19, col=map_info$color)

TextOnStaticMap(mymap, lat = map_info$latitude, lon =

map_info$longitude, labels=paste(map_info

$label,as.character(map_info$pointsize)), cex=0.8, col =

'blue')

 

 

201506매매아파트.xls
3.36MB