使用纬度、经度和方位角在 R 中创建和绘制空间对象
Create and Plot spatial objects in R with lat, long & azimuth
寻求帮助..
我正在尝试基于 lat
、long
和 azimuth
在 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)
#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)
寻求帮助..
我正在尝试基于 lat
、long
和 azimuth
在 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)
#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)