Sunday 19 February 2017

srtm - How to stop gdalwarp creating world-spanning outputs near the dateline?


I'm using gdalwarp to manipulate SRTM tiles near the the dateline (i.e. 180°, aka the antimeridian). SRTM tiles have a very slight (1/2 pixel) overlap with the meridian. You can see this using gdalinfo:


gdalinfo S16W180.hgt
Driver: SRTMHGT/SRTMHGT File Format
Files: S16W180.hgt
Size is 1201, 1201
[...]
Lower Left (-180.0004167, -16.0004167) (180d 0' 1.50"W, 16d 0' 1.50"S)

Upper Right (-178.9995833, -14.9995833) (178d59'58.50"W, 14d59'58.50"S)
[...]

So the source spans the dateline by a tiny amount.


This causes problems with gdalwarp, which ends up creating huge globe-spanning outputs.


gdalwarp -t_srs "epsg:900913" S16W180.hgt test.tif
gdalinfo test.tif
Driver: GTiff/GeoTIFF
Files: test.tif
Size is 1703, 5

[...]
Lower Left (-20037508.330,-1806798.473) (180d 0' 0.00"W, 16d 7'13.00"S)
Upper Right (20032839.451,-1689152.120) (179d57'29.01"E, 15d 5'45.84"S)

Note the longitudes span (almost) the entire globe, and also the number of lines is unexpectedly small (5)


Is this a bug in gdalwarp? If not, what are the correct options to pass to gdalwarp to get a sensible output?




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