R: USCA312/USCA50 - 312/50 cities in the US and Canada
USCA
R Documentation
USCA312/USCA50 – 312/50 cities in the US and Canada
Description
The USCA312 dataset contains the distances between 312 cities in the US
and Canada as an object of class TSP. USCA50 is a subset of
USCA312 containing only the first 50 cities.
The USCA312_map dataset contains
spatial data of the 312 cities.
USCA312 and USCA50 are objects of class TSP.
USCA312_map contains in USCA312_coords the spatial coordinates
of the 312 cities and in USCA312_basemap a part of the
map of North America.
Details
For USCA312_map several packages for geographic data are needed (see
Examples section).
We want to thank Roger Bivand for his help with plotting the map.
Author(s)
Michael Hahsler
Source
John Burkardt, CITIES – City Distance Datasets, Florida State University,
Department of Scientific Computing
Examples
data("USCA312")
data("USCA312_map")
## calculate a tour
tour <- solve_TSP(USCA312)
tour
## load map tools
library("maps")
library("sp")
library("maptools")
## plot map
plot(as(USCA312_coords, "Spatial"), axes=TRUE)
plot(USCA312_basemap, add=TRUE, col = "gray")
## plot tour and add cities
tour_line <- SpatialLines(list(Lines(list(
Line(USCA312_coords[c(tour, tour[1]),])), ID="1")))
plot(tour_line, add=TRUE, col = "red")
points(USCA312_coords, pch=3, cex=0.4, col="black")