1+ # ' @title Communes Coordinates
2+ # ' @name com
3+ # ' @description Coordinates of a set of communes in France. Coordinates are in WGS84.
4+ # ' @source UMS RIATE
5+ # ' @docType data
6+ # ' @examples
7+ # ' \dontrun{
8+ # ' # Load data
9+ # ' data("com")
10+ # '
11+ # ' ### osrmTable ###
12+ # ' # Inputs are data frames
13+ # ' # Travel time matrix
14+ # ' distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
15+ # ' # First 5 rows and columns
16+ # ' distCom$durations[1:5,1:5]
17+ # '
18+ # ' # Travel time matrix with different sets of origins and destinations
19+ # ' distCom2 <- osrmTable(src = com[1:10,c("comm_id","lon","lat")],
20+ # ' dst = com[11:20,c("comm_id","lon","lat")])
21+ # ' # First 5 rows and columns
22+ # ' distCom2$durations[1:5,1:5]
23+ # '
24+ # ' # Inputs are SpatialPointsDataFrames
25+ # ' distCom <- osrmTable(loc = src)
26+ # ' # First 5 rows and columns
27+ # ' distCom$durations[1:5,1:5]
28+ # '
29+ # ' # Travel time matrix with different sets of origins and destinations
30+ # ' distCom2 <- osrmTable(src = src, dst = dst)
31+ # ' # First 5 rows and columns
32+ # ' distCom2$durations[1:5,1:5]
33+ # '
34+ # '
35+ # ' ### osrmRoute ###
36+ # ' # Travel path between points
37+ # ' route <- osrmRoute(src = com[1, c("comm_id", "lon","lat")],
38+ # ' dst = com[15, c("comm_id", "lon","lat")])
39+ # ' # Display the path
40+ # ' plot(com[c(1,15),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
41+ # ' points(route[,1:2], type = "l", lty = 2)
42+ # ' text(com[c(1,15),3:4], labels = com[c(1,15),2], pos = 2)
43+ # '
44+ # ' # Travel path between points - output a SpatialLinesDataFrame
45+ # ' route2 <- osrmRoute(src=c("Bethune", 2.64781, 50.5199),
46+ # ' dst = c("Renescure", 2.369521, 50.72761),
47+ # ' sp = TRUE, overview = "full")
48+ # '
49+ # ' # Display the path
50+ # ' plot(com[c(1,4),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
51+ # ' plot(route2, lty = 1,lwd = 4, add = TRUE)
52+ # ' plot(route2, lty = 1, lwd = 1, col = "white", add=TRUE)
53+ # ' text(com[c(1,4),3:4], labels = com[c(1,4),2], pos = 2)
54+ # '
55+ # ' # Input is SpatialPointsDataFrames
56+ # ' route3 <- osrmRoute(src = src[1,], dst = dst[1,], sp = TRUE)
57+ # ' route3@data
58+ # '
59+ # '
60+ # '
61+ # ' ### osrmTrip ###
62+ # ' # Get a trip with a id lat lon data.frame
63+ # ' trips <- osrmTrip(loc = com[1:9, c(1,3,4)])
64+ # '
65+ # ' # Display the trip
66+ # ' plot(trips[[1]]$trip , col = 1:5)
67+ # ' points(com[1:10, 3:4], pch = 20, col = "red", cex = 0.5)
68+ # '
69+ # ' # Map
70+ # ' if(require("cartography")){
71+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
72+ # ' tilesLayer(x = osm)
73+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE)
74+ # ' points(com[1:9, 3:4], pch = 20, col = "red", cex = 2)
75+ # ' }
76+ # '
77+ # ' # Get a trip with a SpatialPointsDataFrame
78+ # ' trips <- osrmTrip(loc = src)
79+ # '
80+ # ' # Map
81+ # ' if(require("cartography")){
82+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
83+ # ' tilesLayer(x = osm)
84+ # ' plot(src, pch = 20, col = "red", cex = 2, add = TRUE)
85+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE, lwd=2)
86+ # ' }
87+ # '
88+ # '
89+ # ' ### osrmIsochrone
90+ # ' # Get isochones with lon/lat coordinates, default breaks
91+ # ' iso <- osrmIsochrone(loc = c(6.026875, 48.93447))
92+ # ' plot(iso, col = paste0(rep("grey", nrow(iso)), c(seq(80,20,length.out = nrow(iso)))))
93+ # '
94+ # ' # Map
95+ # ' if(require("cartography")){
96+ # ' osm <- getTiles(x = iso, crop = TRUE, type = "osmgrayscale")
97+ # ' tilesLayer(x = osm)
98+ # ' breaks <- sort(c(unique(iso$min), max(iso$max)))
99+ # ' cartography::choroLayer(spdf = iso,
100+ # ' var = "center", breaks = breaks,
101+ # ' border = NA,
102+ # ' legend.pos = "topleft",legend.frame = TRUE,
103+ # ' legend.title.txt = "Isochrones\n(min)",
104+ # ' add = TRUE)
105+ # ' }
106+ # '
107+ # ' # Get isochones with a SpatialPointsDataFrame, custom breaks
108+ # ' iso2 <- osrmIsochrone(loc = src[1,], breaks = seq(from = 0, to = 40, by = 5))
109+ # '
110+ # ' # Map
111+ # ' if(require("cartography")){
112+ # ' osm2 <- getTiles(x = iso2, crop = TRUE, type = "osmgrayscale")
113+ # ' tilesLayer(x = osm2)
114+ # ' breaks2 <- sort(c(unique(iso2$min), max(iso2$max)))
115+ # ' cartography::choroLayer(spdf = iso2,
116+ # ' var = "center", breaks = breaks2,
117+ # ' border = NA,
118+ # ' legend.pos = "topleft",legend.frame = TRUE,
119+ # ' legend.title.txt = "Isochrones\n(min)",
120+ # ' add = TRUE)
121+ # ' }
122+ # '
123+ # ' }
124+ NULL
125+
126+
127+ # ' @title SpatialPointsDataFrame of 10 Communes in France
128+ # ' @name src
129+ # ' @description 8 communes in France. The projection is RGF93 / Lambert-93.
130+ # ' @source UMS RIATE
131+ # ' @docType data
132+ # ' @examples
133+ # ' \dontrun{
134+ # ' # Load data
135+ # ' data("com")
136+ # '
137+ # ' ### osrmTable ###
138+ # ' # Inputs are data frames
139+ # ' # Travel time matrix
140+ # ' distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
141+ # ' # First 5 rows and columns
142+ # ' distCom$durations[1:5,1:5]
143+ # '
144+ # ' # Travel time matrix with different sets of origins and destinations
145+ # ' distCom2 <- osrmTable(src = com[1:10,c("comm_id","lon","lat")],
146+ # ' dst = com[11:20,c("comm_id","lon","lat")])
147+ # ' # First 5 rows and columns
148+ # ' distCom2$durations[1:5,1:5]
149+ # '
150+ # ' # Inputs are SpatialPointsDataFrames
151+ # ' distCom <- osrmTable(loc = src)
152+ # ' # First 5 rows and columns
153+ # ' distCom$durations[1:5,1:5]
154+ # '
155+ # ' # Travel time matrix with different sets of origins and destinations
156+ # ' distCom2 <- osrmTable(src = src, dst = dst)
157+ # ' # First 5 rows and columns
158+ # ' distCom2$durations[1:5,1:5]
159+ # '
160+ # '
161+ # ' ### osrmRoute ###
162+ # ' # Travel path between points
163+ # ' route <- osrmRoute(src = com[1, c("comm_id", "lon","lat")],
164+ # ' dst = com[15, c("comm_id", "lon","lat")])
165+ # ' # Display the path
166+ # ' plot(com[c(1,15),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
167+ # ' points(route[,1:2], type = "l", lty = 2)
168+ # ' text(com[c(1,15),3:4], labels = com[c(1,15),2], pos = 2)
169+ # '
170+ # ' # Travel path between points - output a SpatialLinesDataFrame
171+ # ' route2 <- osrmRoute(src=c("Bethune", 2.64781, 50.5199),
172+ # ' dst = c("Renescure", 2.369521, 50.72761),
173+ # ' sp = TRUE, overview = "full")
174+ # '
175+ # ' # Display the path
176+ # ' plot(com[c(1,4),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
177+ # ' plot(route2, lty = 1,lwd = 4, add = TRUE)
178+ # ' plot(route2, lty = 1, lwd = 1, col = "white", add=TRUE)
179+ # ' text(com[c(1,4),3:4], labels = com[c(1,4),2], pos = 2)
180+ # '
181+ # ' # Input is SpatialPointsDataFrames
182+ # ' route3 <- osrmRoute(src = src[1,], dst = dst[1,], sp = TRUE)
183+ # ' route3@data
184+ # '
185+ # '
186+ # '
187+ # ' ### osrmTrip ###
188+ # ' # Get a trip with a id lat lon data.frame
189+ # ' trips <- osrmTrip(loc = com[1:9, c(1,3,4)])
190+ # '
191+ # ' # Display the trip
192+ # ' plot(trips[[1]]$trip , col = 1:5)
193+ # ' points(com[1:10, 3:4], pch = 20, col = "red", cex = 0.5)
194+ # '
195+ # ' # Map
196+ # ' if(require("cartography")){
197+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
198+ # ' tilesLayer(x = osm)
199+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE)
200+ # ' points(com[1:9, 3:4], pch = 20, col = "red", cex = 2)
201+ # ' }
202+ # '
203+ # ' # Get a trip with a SpatialPointsDataFrame
204+ # ' trips <- osrmTrip(loc = src)
205+ # '
206+ # ' # Map
207+ # ' if(require("cartography")){
208+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
209+ # ' tilesLayer(x = osm)
210+ # ' plot(src, pch = 20, col = "red", cex = 2, add = TRUE)
211+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE, lwd=2)
212+ # ' }
213+ # '
214+ # '
215+ # ' ### osrmIsochrone
216+ # ' # Get isochones with lon/lat coordinates, default breaks
217+ # ' iso <- osrmIsochrone(loc = c(6.026875, 48.93447))
218+ # ' plot(iso, col = paste0(rep("grey", nrow(iso)), c(seq(80,20,length.out = nrow(iso)))))
219+ # '
220+ # ' # Map
221+ # ' if(require("cartography")){
222+ # ' osm <- getTiles(x = iso, crop = TRUE, type = "osmgrayscale")
223+ # ' tilesLayer(x = osm)
224+ # ' breaks <- sort(c(unique(iso$min), max(iso$max)))
225+ # ' cartography::choroLayer(spdf = iso,
226+ # ' var = "center", breaks = breaks,
227+ # ' border = NA,
228+ # ' legend.pos = "topleft",legend.frame = TRUE,
229+ # ' legend.title.txt = "Isochrones\n(min)",
230+ # ' add = TRUE)
231+ # ' }
232+ # '
233+ # ' # Get isochones with a SpatialPointsDataFrame, custom breaks
234+ # ' iso2 <- osrmIsochrone(loc = src[1,], breaks = seq(from = 0, to = 40, by = 5))
235+ # '
236+ # ' # Map
237+ # ' if(require("cartography")){
238+ # ' osm2 <- getTiles(x = iso2, crop = TRUE, type = "osmgrayscale")
239+ # ' tilesLayer(x = osm2)
240+ # ' breaks2 <- sort(c(unique(iso2$min), max(iso2$max)))
241+ # ' cartography::choroLayer(spdf = iso2,
242+ # ' var = "center", breaks = breaks2,
243+ # ' border = NA,
244+ # ' legend.pos = "topleft",legend.frame = TRUE,
245+ # ' legend.title.txt = "Isochrones\n(min)",
246+ # ' add = TRUE)
247+ # ' }
248+ # '
249+ # ' }
250+ NULL
251+
252+
253+ # ' @title SpatialPointsDataFrame of 10 Communes in France
254+ # ' @name dst
255+ # ' @description 10 communes in France. The projection is RGF93 / Lambert-93.
256+ # ' @source UMS RIATE
257+ # ' @docType data
258+ # ' @examples
259+ # ' \dontrun{
260+ # ' # Load data
261+ # ' data("com")
262+ # '
263+ # ' ### osrmTable ###
264+ # ' # Inputs are data frames
265+ # ' # Travel time matrix
266+ # ' distCom <- osrmTable(loc = com[1:50, c("comm_id","lon","lat")])
267+ # ' # First 5 rows and columns
268+ # ' distCom$durations[1:5,1:5]
269+ # '
270+ # ' # Travel time matrix with different sets of origins and destinations
271+ # ' distCom2 <- osrmTable(src = com[1:10,c("comm_id","lon","lat")],
272+ # ' dst = com[11:20,c("comm_id","lon","lat")])
273+ # ' # First 5 rows and columns
274+ # ' distCom2$durations[1:5,1:5]
275+ # '
276+ # ' # Inputs are SpatialPointsDataFrames
277+ # ' distCom <- osrmTable(loc = src)
278+ # ' # First 5 rows and columns
279+ # ' distCom$durations[1:5,1:5]
280+ # '
281+ # ' # Travel time matrix with different sets of origins and destinations
282+ # ' distCom2 <- osrmTable(src = src, dst = dst)
283+ # ' # First 5 rows and columns
284+ # ' distCom2$durations[1:5,1:5]
285+ # '
286+ # '
287+ # ' ### osrmRoute ###
288+ # ' # Travel path between points
289+ # ' route <- osrmRoute(src = com[1, c("comm_id", "lon","lat")],
290+ # ' dst = com[15, c("comm_id", "lon","lat")])
291+ # ' # Display the path
292+ # ' plot(com[c(1,15),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
293+ # ' points(route[,1:2], type = "l", lty = 2)
294+ # ' text(com[c(1,15),3:4], labels = com[c(1,15),2], pos = 2)
295+ # '
296+ # ' # Travel path between points - output a SpatialLinesDataFrame
297+ # ' route2 <- osrmRoute(src=c("Bethune", 2.64781, 50.5199),
298+ # ' dst = c("Renescure", 2.369521, 50.72761),
299+ # ' sp = TRUE, overview = "full")
300+ # '
301+ # ' # Display the path
302+ # ' plot(com[c(1,4),3:4], asp =1, col = "red", pch = 20, cex = 1.5)
303+ # ' plot(route2, lty = 1,lwd = 4, add = TRUE)
304+ # ' plot(route2, lty = 1, lwd = 1, col = "white", add=TRUE)
305+ # ' text(com[c(1,4),3:4], labels = com[c(1,4),2], pos = 2)
306+ # '
307+ # ' # Input is SpatialPointsDataFrames
308+ # ' route3 <- osrmRoute(src = src[1,], dst = dst[1,], sp = TRUE)
309+ # ' route3@data
310+ # '
311+ # '
312+ # '
313+ # ' ### osrmTrip ###
314+ # ' # Get a trip with a id lat lon data.frame
315+ # ' trips <- osrmTrip(loc = com[1:9, c(1,3,4)])
316+ # '
317+ # ' # Display the trip
318+ # ' plot(trips[[1]]$trip , col = 1:5)
319+ # ' points(com[1:10, 3:4], pch = 20, col = "red", cex = 0.5)
320+ # '
321+ # ' # Map
322+ # ' if(require("cartography")){
323+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
324+ # ' tilesLayer(x = osm)
325+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE)
326+ # ' points(com[1:9, 3:4], pch = 20, col = "red", cex = 2)
327+ # ' }
328+ # '
329+ # ' # Get a trip with a SpatialPointsDataFrame
330+ # ' trips <- osrmTrip(loc = src)
331+ # '
332+ # ' # Map
333+ # ' if(require("cartography")){
334+ # ' osm <- getTiles(x = trips[[1]]$trip, crop = TRUE, type = "osmgrayscale")
335+ # ' tilesLayer(x = osm)
336+ # ' plot(src, pch = 20, col = "red", cex = 2, add = TRUE)
337+ # ' plot(trips[[1]]$trip, col = 1:5, add = TRUE, lwd=2)
338+ # ' }
339+ # '
340+ # '
341+ # ' ### osrmIsochrone
342+ # ' # Get isochones with lon/lat coordinates, default breaks
343+ # ' iso <- osrmIsochrone(loc = c(6.026875, 48.93447))
344+ # ' plot(iso, col = paste0(rep("grey", nrow(iso)), c(seq(80,20,length.out = nrow(iso)))))
345+ # '
346+ # ' # Map
347+ # ' if(require("cartography")){
348+ # ' osm <- getTiles(x = iso, crop = TRUE, type = "osmgrayscale")
349+ # ' tilesLayer(x = osm)
350+ # ' breaks <- sort(c(unique(iso$min), max(iso$max)))
351+ # ' cartography::choroLayer(spdf = iso,
352+ # ' var = "center", breaks = breaks,
353+ # ' border = NA,
354+ # ' legend.pos = "topleft",legend.frame = TRUE,
355+ # ' legend.title.txt = "Isochrones\n(min)",
356+ # ' add = TRUE)
357+ # ' }
358+ # '
359+ # ' # Get isochones with a SpatialPointsDataFrame, custom breaks
360+ # ' iso2 <- osrmIsochrone(loc = src[1,], breaks = seq(from = 0, to = 40, by = 5))
361+ # '
362+ # ' # Map
363+ # ' if(require("cartography")){
364+ # ' osm2 <- getTiles(x = iso2, crop = TRUE, type = "osmgrayscale")
365+ # ' tilesLayer(x = osm2)
366+ # ' breaks2 <- sort(c(unique(iso2$min), max(iso2$max)))
367+ # ' cartography::choroLayer(spdf = iso2,
368+ # ' var = "center", breaks = breaks2,
369+ # ' border = NA,
370+ # ' legend.pos = "topleft",legend.frame = TRUE,
371+ # ' legend.title.txt = "Isochrones\n(min)",
372+ # ' add = TRUE)
373+ # ' }
374+ # '
375+ # ' }
376+ NULL
0 commit comments