【问题标题】:Create and Plot spatial objects in R with lat, long & azimuth在 R 中创建和绘制具有纬度、经度和方位角的空间对象
【发布时间】:2017-11-13 18:58:47
【问题描述】:

寻求帮助.. 我正在尝试基于latlongazimuth 在 R 中创建和绘制空间对象。方位角是给定纬度、经度的角度间隔。预期的输出如下图所示,其中对象用蓝色填充:

输入数据:

df <- data.frame(Latitude = c(32.897, 32.897, 32.897, 32.811, 32.811, 32.811),
                 Longitude = c(-97.04, -97.04, -97.04, -97.12, -97.12, -97.12),
                 Azimuth = c(0, 120, 240, 60, 200, 240),
                 Site = c("A", "A", "A", "B", "B", "B"),
                 Sector = c(1,2,3,1,2,3), 
                 stringsAsFactors = F)

【问题讨论】:

标签: r spatial


【解决方案1】:
#Convert df into a spatial object:
library(sp)
coordinates(df)<-~Longitude+Latitude

#Simple plot:
plot(df, col="Blue")

#Plot with icons:
plot(df, col="Blue", pch=24)
plot(df, col="Blue", pch=25, add=TRUE)

#Plot on a map: (You need the associated projection)
proj4string(df) = CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")

library(mapview)
mapview(df)

【讨论】:

    猜你喜欢
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 1970-01-01
    • 2014-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多