1

に極座標で線を描画しようとしていggmapます。一般的な方法は、次の場合にうまく機能しggplotます。

library(ggmap)
library(rgdal)
library(ggplot2)

#####################################


## build data frame with triangulation data

t1 <- c(534325, 4858925, 338, 0955)
t2 <- c(534383, 4859261, 290, 1010)
t3 <- c(534386, 4859011, 301, 1015)

df <- as.data.frame(rbind(t1, t2, t3))
colnames(df) <- c("Easting", "Northing", "Azimuth", "Time")
df$Time <- as.character(df$Time)

## plot coordinates with triangulation

ggplot(df, aes(x=Easting, y=Northing, label=Time)) + 
  geom_point() + 
  geom_text(nudge_x = 50) + 
  geom_spoke(aes(angle = Azimuth, radius = -500)) + 
  theme_bw()

ベースマップなしの三角測量:

img1

これは私が望んでいるものですが、バックグラウンドにベースマップがありません.

ただし、この方法を で試すと、次のようになりggmapます。

## convert utms to lat long

utmcoor <- SpatialPoints(cbind(df$Easting,df$Northing), 
proj4string=CRS("+proj=utm +zone=12"))
lonlatcoor <- as.data.frame(spTransform(utmcoor,CRS("+proj=longlat")))
colnames(lonlatcoor) <- c("lon", "lat")

df$lon <- lonlatcoor$lon
df$lat <- lonlatcoor$lat

## plot on base map

zoom <- 15 

meanlon <- mean(df$lon)
meanlat <- mean(df$lat)

basemap <- get_googlemap(center=c(lon=meanlon, lat=meanlat), zoom=zoom, 
maptype="hybrid")

ggmap(basemap) + 
  geom_point(aes(x=lon, y=lat), colour="red", size=2, data=df) +
  geom_spoke(aes(x=lon, y=lat, angle = Azimuth), data=df, radius=-200) + 
  theme_void()

エラーが発生します

Warning message:
Removed 3 rows containing missing values (geom_segment).

コードはgeom_spoke線がなくても正常に機能し、三角形分割のないベースマップになります。

img2

この関数は、一般的に震えプロットなどに使用されることを理解しています。ggmapサポートしていませんかgeom_spoke?私が気付いていないより良い機能はありますか?

前もって感謝します。

4

1 に答える 1