Below a similar example, using sf and leaflet; plotting the trajectory
on a background map.
library(leaflet)
library(sf)
library(dplyr)
# Generate example data
gen_data <- function(id, n) {
data.frame(
id = id,
date = 1:n,
lat = runif(10, min = -90, max = 90),
lon = runif(10,
Hello,
The following uses ggplot2.
First, make up a dataset, since you have not posted one.
lat0 <- 38.736946
lon0 <- -9.142685
n <- 10
set.seed(1)
Date <- seq(Sys.Date() - n + 1, Sys.Date(), by = "days")
Lat <- lat0 + cumsum(c(0, runif(n - 1)))
Lon <- lon0 + cumsum(c(0, runif(n - 1)))
Place
Probably
sort the data frame by date
Then
plot( mydf$geogr.longitude, mydf$geogr.latitude, type='l')
Search the web for some tutorials
See the help pages for
plot
plot.default
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Dear All,
I have a dataframe with four cols: Date, Placename, geogr. latitude, geogr.
longitude.
How can I plot the path as a line, ordered by the date, with the longitude as
the x-axis and the latitude as the y-axis?
Thank you in advance!
Yours, Ferri
_
4 matches
Mail list logo