Description Usage Arguments Examples
View source: R/line_functions.R
Create a double line or offset line. The double line can be useful for visualizing two-way tracks or emulating objects such as railway tracks. The offset line can be useful to prevent overlapping of spatial lines.
1 2 3 | offset_line(shp, offset)
double_line(shp, width, sides = "both")
|
shp |
SpatialLines(DataFrame) |
offset |
offset from the original lines |
width |
width between the left and righthand side |
sides |
character value that specifies which sides are selected: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
if (require(tmap)) {
### Demo to visualise the route of the Amstel Gold Race, a professional cycling race
tmpdir <- tempdir()
tmpfile <- tempfile()
download.file("http://www.gpstracks.nl/routes-fiets/f-limburg-amstel-gold-race-2014.zip",
tmpfile, mode="wb")
unzip(tmpfile, exdir=tmpdir)
# read GPX file
AGR <- read_GPX(file.path(tmpdir, "f-limburg-amstel-gold-race-2014.gpx"))
# read OSM of Zuid-Limburg
Limburg_OSM <- read_osm(AGR$tracks, ext=1.05)
# change route part names
levels(AGR$tracks$name) <- paste(c("First", "Second", "Third", "Final"), "loop")
AGR$tracks_offset2 <- offset_line(AGR$tracks, offset=c(.0005,0,-.0005,-.001))
tm_shape(Limburg_OSM) +
tm_raster(saturation=.25) +
tm_shape(AGR$tracks_offset2) +
tm_lines(col = "name", lwd = 4, title.col="Amstel Gold Race", palette="Dark2") +
tm_shape(AGR$waypoints) +
tm_bubbles(size=.1, col="gold", border.col = "black") +
tm_text("name", size = .75, bg.color="white", bg.alpha=.25, auto.placement = .25) +
tm_legend(position=c("right", "top"), frame=TRUE, bg.color = "gold") +
tm_view(basemaps = "Esri.WorldTopoMap")
# TIP: also run the plot in viewing mode, enabled with tmap_mode("view")
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.