library(sp)
# Create starting point (Jerusalem)
start = SpatialPoints(
coords = matrix(c(709644.229687171, 3516888.9745794), ncol = 2, byrow = TRUE),
proj4string = CRS("+proj=utm +zone=36 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")
)
start
## SpatialPoints:
## coords.x1 coords.x2
## [1,] 709644.2 3516889
## Coordinate Reference System (CRS) arguments: +proj=utm +zone=36
## +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
# Calculate line
x = coordinates(start)[, 1] + seq(from = 0, by = 1, length.out = 100000)
y = coordinates(start)[, 2] + 10000 * sin(0.001 * x)
line = data.frame(x, y)
coordinates(line) = ~ x + y
proj4string(line) = "+proj=utm +zone=36 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0"
line = as(line, "SpatialLines")
line = spTransform(line, "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
# Map
library(leaflet)
leaflet() %>%
addTiles() %>%
addPolylines(data = line, color = "red")