Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a map image that I have reprojected from OSGB36 to googleMaps projection (EPSG:900913). When I run gdal2tiles on the reprojected map, the results are not alligned with the google maps images (its not just out by a little bit but by 10's of miles).

If I run it through MapTiler (from maptiler.org) it is aligned fine. MapTiler asks for an SRS which I dont specify when using gdal2tiles. So I'm thinking I've missied out a stage?

Also when I run gdalinfo on the warped file, the coords of the corners seem wrong. E.g. for the bottom-left corner the latitude is 51.143906, but it should be 50.955887 for google maps.

I'm usign gdal16 installed by OSGeo4W on Windows7 64-bit.

Warped file here.. https://docs.google.com/leaf?id=0B93lksnTC7_cNzIzZWQ0MDYtMTY5Yy00NjY0LThiMjktZjc2YzA3MmU5NjI4

gdalinfo on warped file...

C:\OSGeo4W\apps\gdal-16\bin>gdalinfo e:buckland_WARPED.tiff
Driver: GTiff/GeoTIFF
Files: e:buckland_WARPED.tiff
Size is 611, 419
Coordinate System is:
PROJCS["Google Maps Global Mercator",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.2572235630016,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-474051.292871501410000,6617009.987366309400000)
Pixel Size = (8.392224865731517,-8.392224865731517)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  ( -474051.293, 6617009.987) (  4d15'30.51"W, 51d 9'49.57"N)
Lower Left  ( -474051.293, 6613493.645) (  4d15'30.51"W, 51d 8'38.06"N)
Upper Right ( -468923.643, 6617009.987) (  4d12'44.69"W, 51d 9'49.57"N)
Lower Right ( -468923.643, 6613493.645) (  4d12'44.69"W, 51d 8'38.06"N)
Center      ( -471487.468, 6615251.816) (  4d14'7.60"W, 51d 9'13.82"N)
Band 1 Block=611x3 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA
Band 2 Block=611x3 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA
Band 3 Block=611x3 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA
Band 4 Block=611x3 Type=Byte, ColorInterp=Alpha

The sequence of commands I run are...

Georeference the OSGB PNG images...

gdal_translate -a_srs EPSG:27700 
-gcp 0 400 241538.5 119812 
-gcp 600 0 244713.5 121928.66666667 
-gcp 0 0 241538.5 121928.66666667 
-gcp 600 400 244713.5 11981
bucklands1.png bucklands1.tiff

Warp into googleMaps projection (EPSG:900913) ...

gdalwarp -s_srs EPSG:27700 -t_srs EPSG:900913 -of GTiff
bucklands1.tiff bucklands1_warped.tiff

Tile (make into googleMap 256x256 tiles) ...

gdal2tiles bucklands1_warped.tiff gmTiles

It works if I by-pass the gdalwarp stage and make google tiles directly from the OSGB36 images. But the image quality is poor as the interpolation is not so good.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

It turns out that if you replace EPSG:900913 with either EPSG:3857 or EPSG:3785 in the gdal warping you get the google-map tiles correctly aligned. Apparently these codes are alternatives for the unofficial googleMaps EPSG:900913. Though there seems to be lots of confusion about which is the correct code - e.g. MapTiler doesnt recognise EPSG:3857.

Anyway this works...

gdalwarp -s_srs EPSG:27700 -t_srs EPSG:3857 -of GTiff
bucklands1.tiff bucklands1_warped.tiff
share|improve this answer

GDAL doesn't agree with you that the map is in OSGB (EPSG:27700) but thinks that it is in EPSG:900913 so I don't know what a reprojection and tiling to the same project will do.

If in doubt use -a_srs to specify the correct projection to gdal.

share|improve this answer
    
I've added the sequence of commands I run to the question incase that helps spot what I'm doing wrong. –  spiderplant0 Dec 19 '10 at 19:49
    
The map isnt OSGB it is EPSG:900913. The original map was OSGB36, then I warped it to googlemaps EPSG:900913. The map link and gdalinfo dump are for the warped map in EPSG:900913. –  spiderplant0 Dec 20 '10 at 12:17
    
I don't think the output coordinate system, "Google Maps Global Mercator" is correct. As it stands, I would assume that the ellipsoidal math was used when converting to Mercator. Google Maps uses spherical math, so you either needs to use a Mercator implementation that supports only the sphere-based equations (or has a projection parameter that will trigger the correct equations), or the geographic coordinate system needs to be based on a sphere of R = 6378137.0 m. The different equations will cause a north-south offset. –  mkennedy Dec 21 '10 at 1:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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