1

I'm currently trying to plot the position of some weather stations in Switzerland. Using pretty standard code with ggmap and geom_point.

register_google(key = "YOUR KEY") 
map <- get_map(location='Bern', zoom=12, maptype = "terrain", color = "color")
ggmap(map) + geom_point( aes(x=stations_coord$long, y=stations_coord$lat)
                         , data = stations_coord, colour = "red", size = 3 )

Problem: All values are misplaced in the plot when comparing to Google Earth

Here is an example for the Bern station. enter image description here

I really don't understand how this is possible. Also there are no threads on this issue anywhere.

enter image description here

Could anyone help me?

2
  • 1
    Are you sure both use the same projection system ? From what I see, Google Maps uses EPSG3857, but I'm not sure ggmap does the same. Jan 8, 2020 at 8:57
  • Oh, thanks I did not knew the difference. I will look into it. for the moment, as i said below: Google Earth is using degrees from 0 to 60 (ex: 46.00 to 46.60) while ggmap uses degrees from 0 to 100 (ex: 46.00 to 46.99) and this seems to be the reason why everything is messed up Jan 8, 2020 at 9:53

1 Answer 1

4

The satellite map and terrain maps use different datums. You are comparing a satellite image with a terrain map - those are different maps and are likely to use different datums. The default datum for google earth (the screencap of your web browser) is WGS84. I don't know what the default datum for the terrain map is but it appears to be different.

Try changing 'maptype = "satellite"' and you will get the same lat/long:

map <- get_map(location='Bern', zoom=12, maptype = "satellite", color = "color")
ggmap(map) + geom_point( aes(x=stations_coord$long, y=stations_coord$lat)
                        , data = stations_coord, colour = "red", size = 3 )

Futher reading on datums: https://en.wikipedia.org/wiki/Geodetic_datum

A side note: accidents happen all the time because of this. Ships reading GPS are using one datum and their charts (maps) are in another datum, so they aren't where they think they are and can crash into stuff. This can also happen with aircraft and in land navigation.

Bottom line: ggmap uses the datums associated with the map that you tell it to look at. You are telling ggmap to look at one type of map (terrain) and comparing it with another type of map (satellite) - probably different datums.

2
  • Hi bstrain,Thank you for this clarification. I will read on it. Yet, Google Earth is using degrees from 0 to 60 (ex: 46.00 to 46.60) while ggmap uses degrees from 0 to 100 (ex: 46.00 to 46.99) and this seems to be the reason why everything is messed up… I will use a simple rule of 3 to modifiy the digits. Thx! Jan 8, 2020 at 9:52
  • 1
    If the datums are the same then you have a pretty easy scaling problem. Fun fact: the scale of 46.00 to 46.60 is "minutes of latitude" and ggmap's 46.00 46.99 are 1/100th scale, like you are used to. One minute of latitude is equal to one nautical mile, which is 6,000ft. Compare this to a statue (normal) mile which is 5,280ft.
    – bstrain
    Jan 8, 2020 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.