[GIS] Transforming EPSG:3857 to EPSG:4326

coordinate systemgdalgoogle maps

I am new to gdal and have a simple question. I want to transform an image from OpenStreetMap projection to Nasa Blue Marble projection. What I understand is that OpenStreetMap projection is EPSG:3857 and Blue Marble projection is EPSG:4326 (http://www.paulillsley.com/gia/index.html).

So, I simply downloaded a sample 256*256 tile like this: http://a.tah.openstreetmap.org/Tiles/tile/0/0/0.png and applied the following command:

gdalwarp -s_srs EPSG:3857 -t_srs EPSG:4326 "0.png" "o_bluemarble.png"

I received the following error:
"Copying color table from 0.png to new file.
ERROR 1: Unable to compute a transformation between pixel/line
and georeferenced coordinates for 0.png.
There is no affine transformation and no GCPs."

From where should I start?

Update 1

I got it. I need to define the bounds. Firstly, I got the bounds:

gdaltransform -s_srs EPSG:4326 -t_srs EPSG:3857
-180 85.05
-20037508.3427892 20036051.9193368 0

I used 85.05 as it is the approximation to infinity in Spherical Mercator used by Bing. Then, I used the following commands:

./gdal_translate -of Gtiff -co "tfw=yes"  -a_ullr -20037508.3427892 20036051.9193368 20037508.3427892 -20036051.9193368 -a_srs "EPSG:3857"  "input.png" "input_tfw.tiff"

./gdalwarp -s_srs EPSG:3857 -t_srs EPSG:4326 -ts 256 128 "input_tfw.tiff" "output.tif"

The problem now is that by comparing an image downloaded from openstreetmap with Blue Marble, the poles are not aligned properly. I mean here Greenland, not the far pole. What do think the problem is?

Best Answer

I'm not sure what your problem is. The image I get from OSM looks like this:

OSM topmost tile

And after running your commands I get this:

WGS84 image

Which looks like how I would expect a lon/lat dataset to look, which is essentially an equirectangular projection:

enter image description here