Understanding Google’s Projection… slightly, anyway

So, as a result of Custom Projection 6: Google Projection, I got pinged by SharpGIS on IRC, and told that the projection I had there was wrong.

He helped me understand what he was using, and I let him know it still wasn’t helping me. So I set up a Virtual Earth + TileCache demo, and he helped me find the missing piece, in the proj4 FAQ:

In this case, and many other cases using spherical projections, the desired approach is to actually treat the lat/long locations on the sphere as if they were on WGS84 without any adjustments when using them for converting to other coordinate systems. The solution is to “trick” PROJ.4 into applying no change to the lat/long values when going to (and through) WGS84. This can be accomplished by asking PROJ to use a null grid shift file for switching from your spherical lat/long coordinates to WGS84.

+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs

The key here was the +nadgrids=@null, which I’d never seen anywhere before.

The end result?

So. Nice. To not feel lost anymore.

Three cheers for sharpgis! Hooray hooray hooray!

6 Responses to “Understanding Google’s Projection… slightly, anyway”

  1. John Cowan Says:

    Boy, I sure wouldn’t want to put my nads on a grid. But to each his own.

  2. archaeogeek Says:

    This is very cool, and I can’t wait to try it out, but unfortunately the link to the source code zip on the map leads to a page not found error…

    Good work though, it looks really nice!

  3. crschmidt Says:

    archaeogeek:

    The URL provided there was accidental, just existed because I copied an existing example of sharpmap’s, not one of my own.

    The setup information for using TileCache + OL is in my post to ol-dev, if that’s what you’re looking for.

  4. kencana Says:

    Hi,

    currently i am trying to use tileCache with google map and geoserver
    as the wms server. i am facing some difficulties in getting the map
    image at certain zoom level. currently the first zoom level (map initial load)
    i set it to 10. and the map image load perfectly. how ever when i try to zoom in i cant see the map image anymore. there is no problem with the zoom out. any idea of this?
    the map coordinate system is WGS84(LL84) and the SRS is EPSG:4326

    thank you

    Regards,
    Kencana

  5. GeoServer » Help us test GeoServer 1.5.2 Says:

    […] in lots of Google Earth output improvements, added GeoRSS, improved the Google Maps demo with a better projection, and added paletted images for faster and lighter image generation.  And of course […]

  6. GeoServer » GeoServer embraces the GeoWeb Says:

    […] with support for the map projection used by Virtual Earth and Google Maps, thanks to SharpGIS and Chris Schmidt.  So now if you use 900913 as the EPSG code for your WMS requests our output will be perfectly […]