[GIS] Reprojecting Google Maps (latlong) to Irish Grid TM65 using spTransform in R

coordinate systemqgisr

I am trying to transform points taken from Google maps (as latitude and longitude) to Irish Grid TM65 using the spTransform in R, and I'm confused on something.

Everything I find on the net tells me google using a mercator projection as so:

"+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"

For the Irish Grid I am using a proj4 string extracted from Irish Census shapefiles

"+proj=tmerc +lat_0=53.5 +lon_0=-8 +k=1.000035 +x_0=200000 +y_0=250000 +datum=ire65 +units=m +no_defs +ellps=mod_airy +towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15"

So that is fine – I plugged all that into R, but was getting wacky answers. So then I fiddled about with different CRS in QGIS to let me see what was going on. Anyhow I found that instead of using the above projection for google, instead by using this projection for the CRS for the points taken from googlemaps then gave me correct projections on my Irish Grid CRS:
""+proj=longlat +datum=WGS84 +no_defs"

How come the projection the entire internet told me to use gave me wacky results and the one I picked almost randomly worked?

This worked in both QGIS and R by the way. I'm reasonably happy with the results – but clearly I'm missing something and I need to understand this properly for the work I am doing

Best Answer

The Google Map uses EPSG:3857 (aka Google Mercator) for displaying the map, but the coordinates you gathered from the map are given in lat/lon degrees. So these are not in mercator projection, which has (not real) metres as units, and you have to set EPSG:4326 WGS 84 as source fro your collected data.

For clarification:

A projection transforms the surface of the earth in a form that can be measured in linear units like metres or feet. A geodetic CRS like EPSG:4326 uses degrees to describe the position on the globe. Every projection is based on a geodetic CRS. So if you have degrees as units, rip of the projection information, and use +proj=longlat with the +ellps, +towgs84 and/or +datum information. In most cases +datum contains +ellps and +towgs84 information internally.

Related Question