I assume that the 'lines' you are referring to are simply the polygon boundaries separating one feature from another. If you just want to display the data and you do not necessarily have to stick with
ggplot2, a possible option would be to use
spplot. Just create a plot of the non-unified polygons with "transparent" line color (see
?sp.polygons) and add the island boundary afterwards using
layer from latticeExtra. Note the use of
unionSpatialPolygons from maptools to merge all polygons into one, thus ending up with the coastline only.
## add 'id' column
gal@data$id <- seq(gal@data$fid) - 1
## unify polygons
gal_union <- unionSpatialPolygons(gal, IDs = rep(1, length(gal)))
## display data with island boundaries only
spplot(gal, "id", col = "transparent", scales = list(draw = TRUE),
at = seq(gal@data$id), col.regions = rainbow(nrow(gal@data))) +
layer(sp.polygons(gal_union, fill = "transparent"))
If I got you wrong and you are trying to merge particular polygons e.g. based on their spatial location, I highly recommend having a deeper look at
?unionSpatialPolygons and, for instance, the related post on Joining polygons in R.
This would be a possible (yet very basic) ggplot2 version of the above code (with the legend disabled).
gal_ff <- fortify(gal)
gal_union_ff <- fortify(gal_union)
ggplot(aes(x = long, y = lat, group = id, fill = id), data = gal_ff) +
geom_path(aes(x = long, y = lat, group = group), data = gal_union_ff,
colour = "black") +
scale_fill_discrete(guide = FALSE) +