-
library(maptools)
-
shppointfile="./testdata/points.shp" # simple points file
-
shppolyfile="./testdata/polys.shp" # simple points file
-
shplinefile="./testdata/lines.shp"
-
#simpleLines@data
-
# Name Value
-
#0 Highway 1
-
#1 Highway 1
-
#2 Arterial 2
-
#3 Arterial 2
-
#4 Arterial 2
-
#5 Arterial 2
-
png('./output/test.png')
-
simpleLines <- readShapeLines(shplinefile) # returns a http:
//sekhon.berkeley.edu/library/sp/html/SpatialLinesDataFrame-class.html
-
colours <- c('red','yellow','green','blue','black') # colors for different road classes
-
plot(simpleLines,col=colours[simpleLines@data$Value], main="Route")
-
legend("topright", fill=unique(simpleLines@data$Value), legend = as.character(unique(simpleLines@data$Value)))
-
# add point layer
-
simplePoints <- readShapePoints(shppointfile)
-
plot(simplePoints,pch=20,add=T) # pch == plotting character
-
# also polylines are possible
-
#simplePolys <- readShapePoly(shppolyfile)
-
#plot(simplePolys,col='blue', add=T)
-
dev.off()