I have an EPSG:4326 tif covering the world that I need to reproject to EPSG:3857 in order to use it with Mapnik to create a map.

When displaying the original tif and leaving Mapnik doing the reprojection, it is working perfectly. But when using GDAL to reproject beforehand, I get a small gap at the right edge of the tif. On the following screenshot of the tif displayed in a mapping app (like Google Maps), you can see it at the middle of the picture:


Here are the commands I used to create the displayed picture:

gdalwarp \
    -multi \
    -t_srs "EPSG:3857" \
    -r cubicspline \
    -tap \
    -tr 10000 10000 \
    world-4326.tif \

gdaldem color-relief \
    world-3857-10000.tif \
    relief-colors.txt \

Is there a way to remove that gap with GDAL?

  • When I look at the right edge of the picture I don't see a gap. Maybe you could draw a circle around the gap to highlight it, and also include a zoomed-in picture? – Stu Smith Aug 30 '18 at 0:04
  • Sorry maybe I wasn't clear enough. The gap is at the right of my tif, and at the middle of the screenshot (the white line). The tif is being displayed in a mapping app (like Google Maps) on the screenshot. – Tim Autin Aug 30 '18 at 1:24
  • maybe your problem is connected with nodata values on the borders of the tiff image - I also had this problem when projecting tiffs to Web Merkator. I used dstNodata=0 parameter in gdalwarp. (if not work, try this gdal.org/nearblack.html or srcNodata=0 parameter) – Jane Aug 30 '18 at 8:28
  • @Jane I don't think so: in my relief-color.txt file, the nodata is set to red, but the gap is of the colour of my background. – Tim Autin Aug 30 '18 at 11:42
  • gdaldem you execute after gdalwarp, aren't you? I believe this white gap appears at gdalwarp step. - I recommend you to take a closer look at the raster border before gdaldem – Jane Aug 30 '18 at 12:26

Seems that the problem came from the fact that EPSG:3857 is only covering 85.06° north and south, and not 90° (like EPSG:4326, the projection of my original tif). When adding an extent to gdalwarp, it is working. Working command:

gdalwarp \
-multi \
-t_srs "EPSG:3857" \
-te_srs "EPSG:4326" \
-te -180 -85.06 180 85.06 \
-r cubic \
~/data/gebco/raw/raw.tif \

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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