I have a raster data and polygons of parks and I want to overlap it on the raster. When I add the polygon it shows here but on ggplot how I add polygons (polygons of parks is like round shapes)on my raster data through ggplot2,. My code is attached below
r <- raster("E:/research/province.tif")
pg <- readOGR("E:/park/1aa.shp") # loadshapfile
plot(r)
plot(pg, add= TRUE,) # it appears like first picture (left).
when I run on ggplot by this code polygons are not there on right hand side picture
centile90 <- quantile(r, 0.90)
df <- as.data.frame(as(r, "SpatialPixelsDataFrame"))
colnames(df) <- c("value", "x", "y")
mybreaks <- seq(0, 500, 50)
ggplot(df, aes(x, y, z = value)) +
geom_contour_filled(breaks = mybreaks) +
geom_contour(breaks = centile90, colour = "pink",
size = 0.5) +
scale_fill_manual(values = hcl.colors(length(mybreaks) - 3, "Zissou1", rev = FALSE)) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
theme_classic() +
theme()