Wednesday 22 February 2017

raster - Making QGIS interpret coordinates as long-lat instead of lat-long?



I am working with the TRMM 3B31 files on precipitation provided by NASA. When I load them on QGIS selecting the WGS84 projection together with other shape files the maps are displayed vertically, i.e. QGIS interpret as latitude what instead is longitude and vice-versa. I have tried gdal_translate option -a_ullr selecting imposing good coordinates but it doesn't solve the problem: the images are only compressed and stretched to satisfy my requirements but this is clearly not what I would like to have.


When you load a .csv file you can choose what has to be the latitude and what the longitude, is there a way to do the same for rasters?


Since I have 193 raster it would be great if you can suggest a command that can be performed iteratively.


enter image description here


The image shows a map of India and the first band of the 3B31 file, i.e. surface precipitation. The two black lines are the 40 and -40 parallel. I would like to have them horizontal and hence that the rain data overlaps with India.



Answer



I tried the 3b31 hdf file from mirador and found the same orientation as you encountered. So I created some GCP to perform a rotation anti-clockwise:


gdal_translate -of VRT HDF4_SDS:UNKNOWN:"3b31.hdf":0 0.vrt
gdal_translate -of VRT -gcp 0 0 -180 -40 -gcp 160 0 -180 40 -gcp 0 720 180 -40 -gcp 160 720 180 40 0.vrt 1.vrt
gdalwarp -r bilinear -t_srs EPSG:4326 1.vrt 0.tif


with this result:


enter image description here


My rotation should follow the Origin=SOUTHWEST metadata tag.


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