地图纽约花旗自行车数据,拉特和长期未显示在地图上

时间:2014-05-05 05:14:41

标签: r plot

我试图在纽约地图上绘制纽约市花旗自行车站数据。

我从here下载了邮政编码数据:

以下是我所做的:

> bike.loc<-bike.train
> nyc.zip<-readShapePoly("nyc_zipcta.shp")

> coordinates(bike.loc)<-c("start.station.id","end.station.id")

> class(bike.loc)

[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"

> str(bike.loc)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 150000 obs. of  15 variables:
  .. ..$ tripduration           : int [1:150000] 970 711 549 883 88 535 975 307 218 542 ...
  .. ..$ starttime              : Factor w/ 41673 levels "7/1/13 0:00",..: 8738 12152 27602 11984 9651 21822 24531 13946 17666 20150 ...
  .. ..$ stoptime               : Factor w/ 41752 levels "7/1/13 0:04",..: 8774 12769 27646 12006 9647 21866 24585 13961 17689 18964 ...
  .. ..$ start.station.name     : Factor w/ 329 levels "1 Ave & E 15 St",..: 9 277 298 321 267 329 71 197 266 182 ...
  .. ..$ start.station.latitude : num [1:150000] 40.7 40.7 40.8 40.7 40.7 ...
  .. ..$ start.station.longitude: num [1:150000] -74 -74 -74 -74 -74 ...
  .. ..$ end.station.name       : Factor w/ 329 levels "1 Ave & E 15 St",..: 193 124 6 159 267 73 76 73 116 227 ...
  .. ..$ end.station.latitude   : num [1:150000] 40.7 40.7 40.8 40.7 40.7 ...
  .. ..$ end.station.longitude  : num [1:150000] -74 -74 -74 -74 -74 ...
  .. ..$ bikeid                 : int [1:150000] 15301 17873 17596 15864 19005 17230 15476 19805 18494 18104 ...
  .. ..$ usertype               : Factor w/ 2 levels "Customer","Subscriber": 2 2 2 2 1 2 1 2 2 2 ...
  .. ..$ birth.year             : Factor w/ 79 levels "\\N","1899","1900",..: 67 37 70 67 1 55 1 45 73 63 ...
  .. ..$ gender                 : int [1:150000] 1 1 1 2 0 1 0 1 1 1 ...
  .. ..$ hour                   : int [1:150000] 19 1 2 8 12 14 15 17 11 9 ...
  .. ..$ day                    : int [1:150000] 15 18 28 17 16 24 26 19 21 22 ...
  ..@ coords.nrs : int [1:2] 4 8
  ..@ coords     : num [1:150000, 1:2] 528 466 495 328 212 430 358 323 482 406 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "start.station.id" "end.station.id"
  ..@ bbox       : num [1:2, 1:2] 72 72 3002 3002
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "start.station.id" "end.station.id"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr NA

我可以制作纽约的情节

plot(nyc.zip)

enter image description here

但我不能在顶部绘制坐标。

plot(bike.loc, add=T, col= "red", pch=15)

我试过了:

EPSG <- make_EPSG()
NY <- with(EPSG,EPSG[grepl("New York",note) & code==2263,]$prj4)

基于此post,但无法使其发挥作用。

如何在地图上绘制纬度/经度?

0 个答案:

没有答案
相关问题