【问题标题】:Converting numeric values of Longitude and Latitude to Spatial Data将经度和纬度的数值转换为空间数据
【发布时间】:2015-07-16 14:47:20
【问题描述】:

我有一个经纬度数据框EuropeanCities

Latitude Longitude
52.00529    4.173965
51.87938    6.268500
43.36661    -8.406812

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

如何使用spfunction 转换这些值的类?

【问题讨论】:

    标签: r geospatial sp


    【解决方案1】:

    只需使用 sp 包中的 SpatialPoints..

        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 
    

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

    【讨论】:

      猜你喜欢
      • 2014-05-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多