Non-square (rectangular) maps in R-ggmap

血红的双手。 提交于 2019-12-06 03:53:51

问题


I need to plot spatial data in a non-square map.

I have been using ggmap, and supposedly you can get non squared maps giving low-west-corner and upper-right-corner coordinates. However, actually it seems it doesn't work (reported here and here).

Anyone knows how to get rectangular maps in R/ggmap?


回答1:


If you can live without Google Maps, there are easy, immediate alternatives (I'd've included CloudMade but I don't have an enterprise account):

library(ggmap)

loc <- c(-96, 29.4, -94, 30.2)

# gmaps

tx_map_gmaps <- get_map(location=loc, source="google", maptype="terrain")
gg <- ggmap(tx_map_gmaps)
gg

# openstreetmap

tx_map_osm <- get_map(location=loc, source="osm")
gg <- ggmap(tx_map_osm)
gg

# stamen

tx_map_stamen <- get_map(location=loc, source="stamen", maptype="toner")
gg <- ggmap(tx_map_stamen)
gg

And, if you're willing to fiddle with initial zoom settings & then cropping (and, perhaps, some tile graininess), you can do it with Google Maps:

tx_map_gmaps <- get_map(location=loc, source="google", maptype="terrain")
gg <- ggmap(tx_map_gmaps)
gg <- gg + scale_y_continuous(limits=c(29.5, 30.0))
gg

(I didn't fiddle with said initial zoom, but you shld be able to get the idea.)



来源:https://stackoverflow.com/questions/31316076/non-square-rectangular-maps-in-r-ggmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!