This is the way I've organized my data to plot the map. I would like to have all points with the split
label Night
in one colour (let's say, blue) and all of the points with the label Day
with a different colour (can't see Day
on the sample below):
> head(times)
DateTime Latitude Longitude split
1: 2018-06-18 03:01:00 -2.434901 34.85359 Night
2: 2018-06-18 03:06:00 -2.434598 34.85387 Night
3: 2018-06-18 03:08:00 -2.434726 34.85382 Night
4: 2018-06-18 03:12:00 -2.434816 34.85371 Night
5: 2018-06-18 03:16:00 -2.434613 34.85372 Night
6: 2018-06-18 03:20:00 -2.434511 34.85376 Night
I've been trying to follow and modify codes from other posts here online but I'm having some trouble since I want my points to be labelled by colour. This is how far I got so far, now I just need some help to plot the points:
# creating a sample data.frame with your lat/lon points
lon <- times$Longitude
lat <- times$Latitude
df <- as.data.frame(cbind(lon,lat))
# getting the map
mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 15,
maptype = "satellite", scale = 2)
# plotting the map, but don't know how to label points according to information on column "split"
ggmap(mapgilbert) +
geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 3, shape = 21) +
guides(fill=FALSE, alpha=FALSE, size=FALSE)
Anyways, any input is appreciated.
Cheers