簡體   English   中英

從ggmap對象獲取邊界框

[英]get bounding box from ggmap object

我在R中使用ggmap庫。我正在嘗試用它下載一個矩形地圖,但我知道它會給我一個正方形。 我只需要返回方塊的邊界框。

library(ggmap)
map <- get_map(c(-65.7,-3.1,-64.4,-2.3),maptype="satellite",filename="map.png")
str(map)

 chr [1:1280, 1:1280] "#294829" "#294829" "#2D512D" "#264425" ...
 - attr(*, "class")= chr [1:2] "ggmap" "raster"
 - attr(*, "bb")='data.frame':  1 obs. of  4 variables:
  ..$ ll.lat: num -3.14
  ..$ ll.lon: num -65.5
  ..$ ur.lat: num -2.26
  ..$ ur.lon: num -64.6

對象有兩個類“ggmap”和“raster”。 我不能在其中使用@或$。 那怎么能從“bb”子對象訪問ll.lat和其他屬性?

你可以這樣做:

> attr(map, "bb")
     ll.lat    ll.lon    ur.lat    ur.lon
1 -3.139567 -65.48877 -2.261646 -64.60986

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM