Wednesday 26 December 2018

gdal - Warping raster to new domain/resolution/projection causes data loss


I am attempting to warp a GTiff from a lat/lon projection to a higher (~2x) resolution Polar Stereographic grid.


In the output GTiff any cells north of 64 deg lat become NaN instead of their actual values.



I am using gdalwarp thusly:


  gdalwarp -t_srs 'wkt string here' -tr 5000 5000 -te -4252339.5,-5302590.0,4597660.5,2747410.25 in.tif out.tif

What could be causing the output raster to have the blank area?


Input extents are [-84.84, -50.19, 55.07, 79.96]. [minLon,maxLon,minLat,maxLat]


Output Coordinate system:


proj4 (+proj=stere +lat_0=90 +lat_ts=60 +lon_0=-100 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs) .


It's standard Polar Stereographic but with Central Meridian at -100 deg and latitude of origin at 60 deg.




The issue was caused by the large difference in coordinate systems. (The domain was self-intersecting in one of the coord systems). It was largely solved by explicitly entering the output extent instead of having GDAL attempt to guess it.



i.e -te -180 0 180 90 was added to the gdalwarp line.



Answer



It works for me with a two-step-transformation:


gdalwarp -overwrite -t_srs "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=-100 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" -of GTiff D:\Download\NEU\ster-wgs84.tif D:/Download/NEU/ster-100-transformed.tif
gdalwarp -overwrite -wo SAMPLE_STEPS=1000 -t_srs "+proj=stere +lat_0=90 +lat_ts=60 +lon_0=-100 +k=1 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" -tr 5000 5000 -te -4252339.5 -5302590.0 4597660.5 2747410.25 ster-100-transformed.tif out.tif

A reason might be that your target extent crosses the 180° line, making the extent a self-intersecting polygon in the source srs WGS84:


enter image description here


enter image description here


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