2

I get the shapeline of newyork census tract from library tigris,after i have a lot of point,in coordinates get from the new york police department

library(tigris)
tracts <- tracts(state = 'NY', county = c(5, 47, 61, 81, 85), cb=TRUE)

new york tracts

for the reproducibility i put some of my point coordinates:

mydata=
        Latitude Longitude
    1   40.71108 -73.85472
    2   40.66888 -73.93251
    3   40.82708 -73.86241
    4   40.68076 -73.95389
    5   40.82449 -73.91253
    6   40.88475 -73.86385
    7   40.76403 -73.97858
    8   40.72972 -73.86397
    9   40.86285 -73.89958
    10  40.57603 -74.09003
    11  40.65729 -73.73765
    12  40.84034 -73.92200
    13  40.76732 -73.98430
    14  40.76039 -73.91510
    15  40.72176 -73.84581
    16  40.69129 -73.91738
    17  40.57487 -74.16973
    18  40.61622 -74.03403
    19  40.63404 -73.96016
    20  40.75528 -73.93629

The main problem (i think) is that Coordinate Reference System (CRS) arguments of my data is NA.So when i try to intersect mydata with tracts, my result is NA,even if i plot the two things together i get only the image of tracts without mydata. I tried, watching around the web:

proj4string(mydata)<-proj4string(tracts)

But this didn't solve my problem.

edit: Also i tried to read the shapefile with readShapePoly that lose the CRS,but it didn't work.

  • 1
    The column names in the header of mydata are inverted. – Antonio Falciano Dec 14 '17 at 12:37
  • @AntonioFalciano You got a point, i fixed it but it doesn't work – gdlzzzz Dec 14 '17 at 12:43
  • @AntonioFalciano no,sorry you have reason, thank you a lot, you saved my life – gdlzzzz Dec 14 '17 at 12:52
1

Because New York City coordinates are about 40.7128° N, 74.0060° W (source: Google), it appears evident that the column names in the header of mydata are inverted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.