Blog about Random things, R and Perl 6

ggmap in R

Advertisements

It is a package interfacing ggplot2 and RGoogleMaps.

For details read this article and here is the cheatsheet.

There are two steps in making a map.

Raster data is downloaded with:

Location specification can be done with:

maptype in ggmap:

Geographic coordinates can be obtained with geocode() function.

Example:

library(ggmap)

## Loading required package: ggplot2

site <- geocode("Pokhara")

## Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Pokhara&sensor=false

Pokhara<- ggmap(get_map(location=site, source="google", zoom=10), extent="panel")

## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=28.237987,83.995588&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false

Pokhara


Fig 1. Pokhara

Advertisements

Advertisements