i have data frame europeancities of latitude , longitude
latitude longitude 52.00529 4.173965 51.87938 6.268500 43.36661 -8.406812 currently these values of numeric class need set them spatial coordinates spatial data
how go converting class of these values using spfunction?
just use spatialpoints sp package..
mydf <- structure(list(latitude = c(52.00529, 51.87938, 43.36661), longitude = c(4.173965, 6.2685, -8.406812)), .names = c("latitude", "longitude"), class = "data.frame", row.names = c(na, -3l)) library(sp) spatialpoints(mydf) # spatialpoints: # latitude longitude # [1,] 52.00529 4.173965 # [2,] 51.87938 6.268500 # [3,] 43.36661 -8.406812 # coordinate reference system (crs) arguments: na (you can supply own proj string , on; see ?spatialpoints).
Comments
Post a Comment