簡體   English   中英

在干凈的美國地圖上映射點(50個州)

[英]Mapping points on a clean US map (50 states)

我想在干凈的美國地圖上繪制點(即,美國地圖僅在沒有地形或文本的白色背景上)。 這是示例數據(我的實際數據有50,000點)。

DATA <- data.frame(Lat=c(47.339374,39.693737, 29.757914, 19.543946,64.668754),
           Long=c(-118.0652,-82.765102,-97.929229,-155.581094,-148.926691),
           State= c("Washington","Ohio","Texas","Hawaii","Alaska") )

我使用地圖嘗試過此操作,但阿拉斯加和夏威夷未出現,我希望它們包含在地圖中。

library(maps)
map("state", interior = FALSE)
map("state", boundary = FALSE, lty = 2, col=8, lwd=0.5, add = TRUE)
title("US map")
points(DATA$Long, DATA$Lat, pch=19, cex=0.5, col= 1:nrow(DATA))

可以從RgoogleMaps在Google地圖的頂部繪制點,但是背景不是白色,因此很難看到這些點。 請指教!

嘗試這樣的事情:

library(ggplot2)
library(ggrepel)
library(mapproj)

us <- map_data('world',
                   c('usa', 'canada', "hawaii", "mexico"))
ggplot()+
  geom_polygon(data=us, aes(x=long, y=lat, group = group), colour="grey20", fill="grey80")+
  geom_point(data = DATA, aes(x=Long, y = Lat), color = "red")+
  geom_text_repel(data = DATA, aes(x=Long, y = Lat, label = State), color = "red")+
  coord_map(projection = "mercator", xlim=c(-170, -50))+
  theme_bw()

在此處輸入圖片說明

暫無
暫無

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

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