Tuesday, 26 May 2015

gdal - Tilemill and GeoTiff not working together


Loading in a geotiff with projection of EPSG:4326 isn't fully rendering:


The original: original geotiff


The original in Tilemill:


original


When using gdalwarp to change the projection from EPSG:4326 to EPSG:3857, tilemill will then load the full geotiff, but the geotiff has a black strip down the center. warped


The warped in Tilemill: warped in Tilemill


The command used for gdalwarp is:


gdalwarp -overwrite -s_srs EPSG:4326 -t_srs EPSG:3857 -r lanczos -srcnodata 0 -dstnodata 0 -of GTiff original.tif warped.tif


The question is, either how do we get gdalwarp to work correctly, without the black strip, or how do we get the original to show up correctly in Tilemill.



Answer



I've had similar issues with gdalwarp producing black strips around image edges. Usually these happen around the international dateline, but your edges appear to be around the central meridian instead so it's no wonder you wind up with an empty strip in the middle of the output GeoTIFF.


Try playing around with the -wo SOURCE_EXTRA=XXX argument. Depending on your image resolution, you might try values anywhere between 100 - 1000 and see where the sweet spot is.


This option specifies a number of extra pixels to use during reprojection that should help minimize the effect. You may still wind up with a small black strip, but it shouldn't be as noticeable.


More information here.


If that doesn't work, you might also try increasing work/cache memory using -wm XXX and --config GDAL_CACHEMAX XXX, where XXX is an integer representing megabytes.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...