Search code examples
rggplot2spatialrgdal

How to plot data on a map without using Google map (image)?


I have a csv file with variables name "Latitude","Longitude","PM10 concentration". You can download data here. I want to plot PM10 data on a map of South Korea according to their latitude and Longitude. Also I want to show them as bubble with different size and color.

Following this example I have already plotted PM10 data on Google Map. But now I want do this without using Google map rather by creating spatial object or in any other way.

I tried to write some code but I have download the spatial data for administration area (GADM) of South Korea. But I am not sure that approach is right or wrong.

library(rgdal)
library(ggplot2)
library(maptools)

map<-readOGR('D:/BACKUP/R/GSTAT/R File/shape file korea map',layer ='KOR_adm2')
summary(kmap)

EPSG<-make_EPSG()
EPSG[grepl("WGS 84$", EPSG$note), ]

kmap84<-spTransform(kmap, CRS("+init=epsg:4326"))
kmaps<-fortify(kmap84)

I don't understand what should I do next.


Solution

  • Here's an example:

    library(raster)
    library(ggplot2)
    download.file("https://docs.google.com/uc?id=0ByY3OAw62EShakxJZkplOXZ0RGM&export=download", tf <- tempfile(fileext = ".csv"))
    df <- read.csv(tf, row.names = 1)
    skorea <- getData("GADM", country = "South Korea", level = 2)
    skorea <- fortify(skorea)
    ggplot() +  
      geom_map(data = skorea, map = skorea, aes(x = long, y = lat, map_id = id, group = group), 
               fill = NA, colour = "black") + 
      geom_point(data = df, aes(x = LON, y = LAT, size = PM10), colour = "red", alpha = .5) + 
      scale_size(range = c(1, 5))
    

    enter image description here