Tuesday, 3 November 2015

gdal - Holes between imagery tiles projected using gdalwarp


I am having the following issue when reprojecting imagery tiles using gdalwarp.


These are 4096x4096 imagery tiles, which I'm gdalwarp'ing from WGS84 to a State Plane projection. When reprojected, the tiles, naturally, overlap, and so have added an alpha channel which takes care of it nicely.


However, when viewed together, after reprojection, the tile edges don't quite match up. Note also that this is NOT an issue or artifact with the alpha channel---I can use nodata instead of alpha, or just leave the area black, and the edges remain broken, with holes, just the same. Below is an example of a 1:80 scale crop of the seam between two tiles after projection. It maintains this pattern of holes along the entire seam between two tiles.



The basic command I'm using looks something like this:



gdalwarp -s_srs EPSG:4326 -t_srs EPSG:0000 /path/to/source.jp2 /path/to/dest.tif



I've exhausted most of the options I can think of from gdalwarp ( http://www.gdal.org/gdalwarp.html ) and the warp options ( http://www.gdal.org/structGDALWarpOptions.html#a0ed77f9917bb96c7a9aabd73d4d06e08 ), including different resampling methods, increasing the SAMPLE_STEPS density, and playing with additional SOURCE_EXTRA pixels. All with no change whatsoever.


I realize creating a mosaic first, reprojecting, and then retiling would be one way around this issue, but I'm dealing with tens of thousands of these ~16 megapixel tiles, so as far as I can tell, a mosaic is not feasible.


Any ideas on an approach to deal with these edge inaccuracies? Thanks!


Seam between tiles



Answer



Creating a mosaic from your source images takes only a few seconds if you use GDAL virtual raster as output. Read



http://www.gdal.org/gdal_vrttut.html and http://www.gdal.org/gdalbuildvrt.html


Often the artifacts like you have can also be avoided by taking care that the individually warped images are aligned to use a common canvas. This can be achieved by using -tap parameter together with -tr parameter. I would try that first. Read about -tap from http://www.gdal.org/gdalwarp.html


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...