I have a data frame with the coordinates of tweets, such as:
library(ggplot2) df <- data.frame(long = c(-58.1, -58.2, -58.3, -58.4, -58.5, -55), lat = c(-34.1, -34.2, -34.3, -34.4, -34.5, -25))
I would like to build a metropolis of Buenos Aires, known as AMBA. It is determined by the region: longitud: (-58, -59) latitude: (-34, -35)
I have a row in my data frame that is outside the scope of AMBA. (important for question (2))
Here is what I tried:
Download Argentina Map Information
con <- url("http://gadm.org/data/rda/ARG_adm2.RData") print(load(con)) close(con) ggmap <- fortify(gadm, region = "NAME_2")
Set limits for the schedule to include only AMBA
lim <- data.frame(lon = c(-59, -58), lat = c(-35, -34))
Plot
ggplot(data=ggmap, aes(x=long, y=lat)) + scale_x_continuous(limits = c(-59,-58)) + scale_y_continuous(limits = c(-35,-34)) + geom_polygon(data = ggmap, fill = "grey80", aes(group=group)) + geom_path(color="white",aes(group=group)) + geom_point(data = df, aes(x = lon, y = lat, colour = "red"), alpha = 30/100)
QUESTIONS:
- The main problem is that the areas of political borders are not complete in foreign countries, so the map looks strange. Will there be a way around this?
- Do I have to multiply the data frame to save the observations inside the AMBA area or can I directly make a plot and select the area of interest to me. I believe this is what scale_x_continuous (limits = ...) does.
r ggplot2 gis
marbel
source share