mat mat - 7 months ago 43
R Question

How do I use the Google Maps coordinate system?

I don't understand how the coordinate system works in the plotGoogleMaps package.

For example, lets say I wanna plot these coordinates (Eiffel Tower):

lat <- 48.858264 # y
lon <- 2.294557 # x

Here's my code:

coords <- data.frame(lon, lat)
coordinates(coords) <- ~ lat + lon
proj4string(coords) <- CRS('+init=epsg:28992')
plotGoogleMaps(coords, filename = 'map.htm')

However the location I obtain is completely different to what i was expecting. What am I doing wrong?

Inverted lat and lon


You seem to provide EPSG:4326 coordinates (WGS84) but use the EPSG:28992 in your projection.

Try to change

proj4string(coords) <- CRS('+init=epsg:28992')


proj4string(coords) <- CRS('+init=epsg:4326')