°øÀ¯ÀÚ·á HOME > ÀÚ·á½Ç > °øÀ¯ÀÚ·á
 
[Àç´É±âºÎ]Áöµµ±×¸®±â
°ü¸®ÀÚ 17-08-12 10:16 2,121

#1.¼¼°èÁöµµ ±×¸®±â

install.packages("maps")
library(maps)
map()


#2. ¾Æ½Ã¾Æ Áöµµ ±×¸®±â

install.packages("ggplot2")
library(ggplot2)

# ¿øÇÏ´Â ³ª¶ó¸¦ map_data¸¦ ÅëÇÏ¿© ºÒ·¯¿À±â
asia <- map_data("world",
                 region = c("China","Japan","North Korea","South Korea", "India"))

# geom_polygonÀ» ÀÌ¿ëÇÏ¿© ³ª¶óµéÀÇ Å׵θ®¸¦ ±×¸®°í »ö±ò·Î ä¿ì±â
ggplot(asia, aes(x=long, y=lat, group=group, fill=region))
+ geom_polygon(colour="black")
+ scale_fill_brewer(palette="Set1")



#3.´ëÇѹα¹Áöµµ ±×¸®±â
korea <- map_data("world", region = c("North Korea", "South Korea"))
ggplot() + geom_polygon(data=korea, aes(x=long, y=lat, group=group, fill=region),
                        colour="black") + scale_fill_brewer(palette="Set1")
#map(database="world", region="Japan")


#4.¼­¿ïÁöµµ ±×¸®±â
install.packages("ggmap")

library(ggmap)

seoul <- get_map("Seoul, South Korea", zoom=13, maptype = "roadmap")
ggmap(seoul)

#ÁöµµÀÇ Á¾·ù: satelite, hybrid, toner, watercolor, terrain, terrain-background, toner-lite
seoul <- get_map("Seoul, South Korea", zoom=13, maptype = "terrain")
ggmap(seoul)


#5.¿ì¸® ÁýÀ» Áöµµ¿¡¼­ Ç¥½ÃÇϱâ
library('ggmap')
library('ggplot2')

home <- get_map("Seoul, South Korea", zoom=11, maptype = "roadmap")
location <- data.frame(name = "Áý", LON = 127.0525440, LAT = 37.5961950)
ggmap(home) + geom_point(data = location ,aes(x=LON, y=LAT), size=5, colour = "red")


#6.¼­¿ï½Ã 2È£¼± ÁöÇÏö¿ª À§Ä¡ Ç¥½ÃÇϱâ
library(ggplot2)
library(ggmap)

subway <- read.csv("subway.csv",header=T)
subway
line2 <- subset(subway, È£¼±%in%"2")
line2

# À̸§ º¯°æÇϱâ
names(line2)[names(line2) == "XÁÂÇ¥(WGS)"] <- c("LON")


seoul <- get_map("Seoul, South Korea", zoom=13, maptype = "roadmap")

seoul.map <- ggmap(seoul) + geom_point(data=line2, aes(x=LON, y=LAT), size=3, alpha=0.7, col="red")

seoul.map + geom_path(data=line2, aes(x=LON, y=LAT), size=3, linetype=3, col="green")
+ geom_text(data=line2, aes(x=LON, y=LAT+0.001, label=Àüö¿ª¸í), size=3)