Hello,
I am trying to create a map of Canada using ggplot2 that I can add labels to. I would like to label the location of specific treatment centers, mostly located in major cities.
I used the StatsCan census subdivisions cartographic boundary file (2016 Census Boundary files) to produce a map of Canada.
#shapefile
s_census <- shapefile("~/data/lcd_000b16a_e.shp")
s_census_fortified <- tidy(s_census)
map
ggplot(data = s_census_fortified,
aes(x = long, y = lat, group = group, fill = "id")) +
geom_polygon(color = "black", fill = "white", size = 0.1) +
guides(fill = "none") +
theme_minimal()
Next I try to use geom_text to label specific locations on the map pulled from a separate file called mapdata_AML. The long and lat in this file were manually extracted from Google using street address information.
ggplot(data = s_census_fortified, aes(x = long, y = lat, group = group, fill = "id")) +
geom_polygon(color = "black", fill = "white", size = 0.1) +
guides(fill = "none") +
geom_text(data = mapdata_AML, aes(label = Centre, x = long, y = lat, group = group),
label.padding = unit(0.55, "lines"),
label.size = 0.35,
color = "black",
fill="gray90", alpha = 0.4 ) +
theme_minimal()
But all of the labels are off the map. I don't understand why there is no overlap between my label file and the shapefile.
Can anyone help? Have I done something wrong with the shapefile import and transformation?
Thank you.