I am creating a map with ggplot in R. The map contains shapefiles (lines and points) of the sf class, for which I would like to create a legend, but I can’t figure out how to do it. The legend should include the glyph of the point shapefile in the corresponding color(red square) and line for the line shapefile in the corresponding color (black line), and title what it shows (red square is "discovery" and black line is "path"). Can anybody help?
Please see my code here:
ggplot(data = SF_NP_boundary)+
geom_sf(fill = "antiquewhite1")+
geom_sf(data = SF_PATROL_ROUTE, size = 0.1, fill = "black") +
geom_sf(data = SF_PRESENCES, size = 4,
shape = 23, fill = "red") +
theme(panel.grid.major = element_line(colour = gray(0.2), linetype = "dashed",
size = 0.1), panel.background = element_rect(fill="aliceblue"),
panel.border = element_rect(fill = NA))+
annotation_scale(location = "bl", width_hint = 0.5, height = unit(0.15, "cm"), pad_y = unit(0.15, "in")) +
annotation_north_arrow(location = "bl", which_north = "true",
pad_x = unit(0.1, "in"), pad_y = unit(0.35, "in"),
style = north_arrow_fancy_orienteering)