문제

For days i'm searching on the web the most simple way to plot a shaded polygone above a map generated with the get_map command. For the polygone I have a few (latitudes, longitudes) points.

I know how to do this with *.shp files must it's too much time consuming for simple applications.

If someone has a good tip to do this with in a simple way with R 3.0.2 ;-)

도움이 되었습니까?

해결책

You can use geom_polygon to draw a polygon. Try to add the following command to your plot:

+ geom_polygon(data = yourdata, aes(x = lon, y = lat))

다른 팁

Here is my result:

library(ggmap)
Longitude <- c(6.486318,7.290372,8.573611,6.811188,6.486318)
Latitude <- c(46.47924,46.15687,47.40744,46.99614,46.47924)
mydata <- as.data.frame(cbind(Longitude,Latitude))
mydata
swiss <- get_map("Switzerland",zoom=8)
ggmap(swiss)+
geom_polygon(data=mydata,aes(x=Longitude,y=Latitude),alpha=0.3,colour="red",fill="red")+
geom_path(data=mydata,aes(x=Longitude,y=Latitude),colour="white",alpha=0.7,size=3)+
annotate("point",x=7.257885,y=46.79049,size=7)+
annotate("text", x=7.257885,y=46.79049,label="Golden Swiss Area",colour="white",size=3)

Resulting map

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top