1

我有一个EuropeanCities纬度和经度的数据框

Latitude Longitude
52.00529    4.173965
51.87938    6.268500
43.36661    -8.406812

目前这些值属于数字类,但是我需要将它们设置为空间数据的空间坐标

如何使用该sp函数转换这些值的类?

4

1 回答 1

0

只需SpatialPointssp包装中使用..

    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 

(您可以提供自己的 proj 字符串等;请参阅?SpatialPoints)。

于 2015-07-17T00:34:32.663 回答