0

Looking for some help.. I am trying to create and plot spatial objects in R based on lat, long & azimuth. Azimuth is the angle separation at a given lat, long. Expected output as shown in below image where the objects are filled with blue color:

enter image description here

Input data:

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)
Michael Harper
  • 11,715
  • 2
  • 51
  • 69
Kg211
  • 95
  • 5
  • What have you tried already? This question is quite broad generally and answered in many existing posts on StackOverflow: https://stackoverflow.com/questions/29736577/how-to-convert-data-frame-to-spatial-coordinates – Michael Harper Nov 12 '17 at 17:34

1 Answers1

0
#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)
Kvasir EnDevenir
  • 828
  • 10
  • 23