在地图上绘制点

时间:2017-02-27 01:06:31

标签: r dictionary ggplot2

我试图在地图上绘制一系列点。 我有两个数据集nt和患者 - nt是SpatialPolygonsDataFrame,患者是data.frame 我可以绘制nt但是行  points(patients$long, patients$lat, col ="green", cex=.6) 没有效果

请注意,患者的某些行在nt之外 我可以自己策划患者。

一些代码 - 我希望它正确格式化 @ R,S

library(ggplot2)
plot.new()
map <- ggplot() +
geom_path(data = nt, 
      aes(x = long, y = lat, group = group),
      color = "gray", size = .2
)
map <- map + theme_bw()
print( map)
points(nt_pats$long, nt_pats$lat, col ="green", cex=.6)

最初我想在nt上绘制患者 后来我想说明患者人数及其家庭住址。

先谢谢米克

示例数据

  

头(患者)              locality long lat No.patients State.Code Postcode State.Abbr       1 BLACKMANS BAY 147.322 -42.997 1 6 7052 TAS       2 SOUTH HOBART 147.310 -42.896 4 6 7004 TAS       3 BELLERIVE 147.371 -42.873 2 6 7018 TAS       4 LENAH VALLEY 147.287 -42.872 1 6 7008 TAS       5 NEW NORFOLK 147.059 -42.781 1 6 7140 TAS       6 KEMPTON 147.200 -42.532 1 6 7030 TAS

> head(nt,1)
An object of class "SpatialPolygonsDataFrame"
Slot "data":
  STATE_CODE CD_CODE06 SLA_CODE06 SLA_NAME06 LGA_CODE06 LGA_NAME06
0          7   7010101  705051004      Alawa      71000 Darwin (C)

Slot "polygons":
[[1]]
An object of class "Polygons"
Slot "Polygons":
[[1]]
An object of class "Polygon"
Slot "labpt":
[1] 130.87870 -12.37927

Slot "area":
[1] 2.317102e-05

Slot "hole":
[1] FALSE

Slot "ringDir":
[1] 1

Slot "coords":
          [,1]      [,2]
 [1,] 130.8756 -12.38281
 [2,] 130.8753 -12.38126
 [3,] 130.8761 -12.38112
 [4,] 130.8775 -12.38087
...
Slot "plotOrder":
[1] 1

Slot "labpt":
[1] 130.87870 -12.37927

Slot "ID":
[1] "0"

Slot "area":
[1] 2.317102e-05



Slot "plotOrder":
[1] 1

Slot "bbox":
        min       max
x 130.87529 130.88214
y -12.38281 -12.37602

Slot "proj4string":
CRS arguments:
 +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs 

0 个答案:

没有答案