Plotting shapefiles with attributes using ggplot

Hi Solomon,

Welcome.

I recommend trying the sf package, as in my opinion it simplifies a lot of the handling of maps.

For future reference, a reproducible example to work with would help to be certain, but try something like this:

library(ggplot2)
library(sf)

shp <- read_sf('Duration.shp')
ggplot(shp) + geom_sf(aes(colour = Duration))

or, if the rivers are polygons rather than lines:

ggplot(shp) + geom_sf(aes(fill = Duration))

Ron.

1 Like