[英]Plotting map for UK, in ggmap & ggplot2
全部,
如果
Germany = map_bounds <- c(left = 5, bottom = 47, right = 16, top = 56)
什么是英國?
英國 =
嘗試以下任何選項:
library(maps)
library(mapdata)
#Option 1
map('worldHires',
c('UK', 'Ireland', 'Isle of Man','Isle of Wight'),
xlim=c(-11,3), ylim=c(49,60.9))
Output:
或者:
library(ggplot2)
library(maps)
#Data
worldmap = map_data('world')
#Option 2
ggplot() + geom_polygon(data = worldmap,
aes(x = long,
y = lat,
group = group,
),
fill = 'gray90',
color = 'black') +
coord_fixed(xlim = c(-10,3),
ylim = c(50.3, 59))
Output:
感謝上面的幫助,這里是幾乎完整的代碼,我只需要了解哪個位以及如何將熱圖多邊形修改為透明,它們目前阻礙了下面的 map。
庫(ggplot2) 庫(ggmap) 庫(RColorBrewer)
coords.data <- read.csv(file="~/Desktop/locations.csv")
-UK bounds map_bounds <- c(left = -2.5, bottom = 51, right = 1.5, top = 54)
coords.map <- get_stamenmap(map_bounds, zoom = 10, maptype = "toner-lite")
coords.map <- ggmap(coords.map, extent="device", legend="none")
-heat map layer: Polygons with fill color based on relative frequency of coordinates coords.map <- coords.map + stat_density2d(data=coords.data, aes(x=Longitude, y=Latitude, fill=..level.., alpha=..level..), geom="polygon")
-填充密度輪廓 coords.map <- coords.map + scale_fill_gradientn(colours=rev(brewer.pal(7, "Spectral")))
- 添加坐標,顏色為紅色並定義形狀 - 形狀: http://sape.inf.usi.ch/quick-reference/ggplot2/shape
coords.map <- coords.map + geom_point(data=coords.data, aes(x=Longitude, y=Latitude), fill="red", shape=23, alpha=0.4)
coords.map <- coords.map + theme_bw() ggsave(filename="./coords.png")
除了@Duck 的答案,您還可以通過在epsg.io上搜索該國家/地區來獲得任何國家/地區的 WGS84(即經度和緯度)范圍。
例如,英國使用英國國家電網 (EPSG 27700) ,因此如果您使用 select,該投影將為您提供 WGS84 邊界,您可以將其用於 map 邊界。
WGS84 bounds:
-8.82 49.79
1.92 60.94
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.