[GIS] Importing google maps/bing points: which projection

coordinate systemgoogle-maps-apirsf

I am trying to use data imported through one of the google maps/Bing API, and am confused about the projection. Using the APIs, data comes under a non-geographic format, such as json or xml, try:

http://maps.googleapis.com/maps/api/geocode/json?address=Davis&sensor=false

It seems that the projection of google maps is epsg:3857. However, according to this stack post and this page, things are more complicated:

All of this further confused by that fact that often even though the
map is in Web Mercator(EPSG: 3857), the actual coordinates used are in
lat-long (EPSG: 4326).

So what should I do, when I import a point, and want it, say in the final projection WGS 84 (epsg:4326)? I tried:

  1. Declaring as 3857, then converting to 4326: gives me a point out of space (see point_3857_to_4326 in code below: -0.00109, 0.00034)
  2. Declaring directly as 4326: seems to make sense (see point_4326)

Where is the issue? That the points themselves are not in 3857, or that they are, but conversion is not well done? This post indicates in chapter "the solution" how to do the conversion, but I just don't get it…

Example with R:

# not run: library(ggmap)
# geocode("Davis", output="latlon")

library(sf)
point <- st_point(c(-121.7405167, 38.5449065)) 

point_4326 <- st_sfc(point, crs=4326)
point_3857_to_4326 <- st_sfc(point, crs=3857) %>%
  st_transform(4326)

point_4326
point_3857_to_4326

Best Answer

Google Maps and similar products all use EPSG:3857 (Spherical Mercator, aka "Web Mercator") to display their maps in browsers and the like. Services that also offer bitmap tiles are likely in EPSG:3857 as well. Why: it's a decent projection if you want the "world" to display like people expect it to be.

The APIs, kmz, kml files, and the like of these use lat,lon coordinates. Those are in EPSG:4326 (aka WGS84).

So these services do a behind the scenes re-projection.

Some interfaces actually use both coordinate systems in one URL, but that's a bit rare AFAIK: e.g.: http://historicalmaps.arcgis.com/usgs/index.html?lat=38.89872390784443&lng=-77.03654999999998&zl=17&minDate=1885&maxDate=1993&oids=&dlids=&f=&clickLat=-8575667.726977706&clickLng=4707013.772000514

[it's the white house]

has both in there: lat=38.89872390784443&lng=-77.03654999999998 in WSG84 for where to center the image and clickLat=-8575667.726977706&clickLng=4707013.772000514 (which I suspect being 3857 - or something similar) where I clicked (more or less in the center).