I have Particulate Matter concentration difference (After - Before) for Port of Los Angeles area. I am trying to use ggmap to plot concentration contours on map but the result looks way different. The code I used is shown below (and data is below the code):
Code
install.packages('ggmap')
library(ggmap)
PM = read.csv('data.csv', stringsAsFactors = FALSE)
Get Longitude and Latitude
geocode("Port of Los Angeles") # Not centered
geocode("Compton, CA") # Now centered
Use Compton LON and LAT
POLA = c(lon = -118.220071, lat = 33.895849)
POLA.map = get_map(location = POLA, zoom = 10, color = 'bw')
ggmap(POLA.map) + geom_point(data = PM, mapping = aes(Longitude, Latitude)) +
stat_density2d(data = PM, mapping = aes(x = Longitude, y = Latitude, fill=..level..), geom = "polygon", alpha = 0.3, contour = TRUE)
However, the contour plot should have a pattern like this:
https://drive.google.com/file/d/0B3XVjcsci0y3VDBTc01PYkhOckE/view?usp=sharing
ggplot(PM, aes(UTM.X, UTM.Y)) + geom_tile(aes(fill = Value), alpha = 0.8, color = "black") +
scale_fill_gradient(low = 'green', high = 'red')