我正在尝试使用ggmap绘制更广阔的印度洋地图。我选择了要构成地图拐角的各种纬度/经度。但是,当我尝试用R绘制地图时,它会生成所有大洲的地图,而不仅仅是我要绘制的区域。上面的地图是代码输出的内容,我在红色框中突出显示了要绘制的区域。
这是我尝试过的代码:
bbox <- make_bbox(lon = data$Longitude, lat = data$Latitude, f=1)
map <- get_map(location = bbox, source = "google", maptype = "satellite")
plot <- ggmap(map)
数据:
structure(list(Latitude = c(18.682744, -27.706318, 17.65651,
-21.006735), Longitude = c(46.252432, 43.179057, 100.89364, 104.064258
)), class = "data.frame", row.names = c(NA, -4L))
您的值f = 1,太大了一个分数,这扩大了地图的大小。
data<-structure(list(Latitude = c(18.682744, -27.706318, 17.65651,
-21.006735), Longitude = c(46.252432, 43.179057, 100.89364, 104.064258
)), class = "data.frame", row.names = c(NA, -4L))
bbox <- make_bbox(lon = data$Longitude, lat = data$Latitude, f=1)
bbox
#left bottom right top
#-17.70614 -74.09538 164.94946 65.07181
如果您查看边界框,则从上到下是从Fromm 65 North到-74 South。
如果设置f = 0.05(默认值),则地图的大小更易于管理。
bbox <- make_bbox(lon = data$Longitude, lat = data$Latitude, f=0.05)
box
# left bottom right top
#40.13480 -30.02577 107.10852 21.00220
现在,盒子的纬度从21北更改为-30南,非常接近您想要的尺寸。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句