Is it possible using any of the command line GDL tools such as gdalwarp, etc to perform a rotation of DEM data – a GeoTiff for example?
Anyone know how to do this?
UPDATE1
After clearing out GeoTiff tags and loading my plain Tiff into QGIS with a modified TFW file – I am able to successfully view and export my rotated Tiff DEMs. From what I can tell, the elevation resolution is preserved! However, upon export I decided to view them in MicroDEM and noticed some blocky artifacts. I went back to QGIS and saw the same thing:
MicroDEM
QGIS
Is this perhaps an error in my transform calculations? I did a -10 degree rotation – Started with this:
0.0000925926
0.0000000000
0.0000000000
-0.0000925926
-157.0956018521
20.9603240742
Ended up with this:
0.00009118591
-0.00001607853
-0.00001607853
-0.00009118591
-157.0956018521
20.9603240742
Math look ok there? What else could this be?
Have you seen this before? Can this not be avoided when performing such a rotation?
(Should I move this updated section to a new gis.stackexchange.com question?)
UPDATE2
I performed the same process with a few additional rotation angles, specifically 45° and 90°. The blocky artifacts seem much less severe to the point that they almost don't appear at all. However, another more obvious problem arises at these rotations. The data appears to brighten and become more white overall at certain rotations. In other words, the elevation rises generally in the entire model and detail is therefore lost. First, notice the original view in QGIS:
Original (no rotation), 45° and 90° – respectively:
In fact, the same problem is occurring with my original -10 degree rotation (though more subtle):
This leads me to believe that if the data is rotated at all then I will get this clipping effect. Remember, this is the data as QGIS presents it upon opening the .TIFF file. I have not exported anything or applied any special processes beyond modifying the .TFW file.
What in the world could be going on here? How can I avoid these distortions when rotating the data?
UPDATE3
As noted in the comments, I resolved the first issue using the bi-linear re-sampling. The second issue was resolved by setting the min/max correctly.
Best Answer
You can create a local CRS with an oblique mercator projection, and transform the data with gdalwarp and gdal_translate into it. See my advice here:
Using customized Coordinate System in ArcGIS Desktop?
This should work with 16-bit or grayscale data the same way. Paletted colours shoud be expanded to RGBA in advance.
UPDATE
Using QGIS, create custom CRS without (tmerc) and with (omerc) the rotation, using the same coordinates for the center of projection:
In a first run, use
Raster -> Projections -> Warp
on your tif to the rotation point:In QGIS, you will not see a difference, because the pixel values have not changed. Then use
Raster -> Conversion -> Translate
:and the result looks like expected:
Make sure to copy the style from the unrotated to the rotated layer to see the same styling.