Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
- ## 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).
Add Comment
Please, Sign In to add comment