Hello,
I am new to this forum and topic, so please forgive me if this is a trivial question.
I am having trouble converting GDAL TIF images to FITS files that can be used by HipsGen. More precisely, the final render generated by HipsGen is different to what I expected. Some transformations seem to be happening that I don’t understand, which ruins the tile generation.
To perform this conversion, I follow these steps:
I start with the command:
gdal_translate source.tif destination.fits
Once all the TIF images have been processed, I generate the tiles using this command:
java -jar .\Hipsgen.jar in=“C:\Users\Ordinateur\Desktop\fits” out=“./” id=“moon/dem” CLEANALL INDEX TILES PNG
It says that, by default, HipsGen generates 512x512 tiles. I would prefer to use 256x256 tiles, but when I try this, it does not work.
java -jar .\Hipsgen.jar in=“C:\Users\Ordinateur\Desktop\fits” out=“./” id=“moon/dem” tileWidth=256 CLEANALL INDEX TILES PNG
And this error shows up every time; I have no idea why. The generation happens in a new folder, so it should not have pre-existing tiles of a different order.
INFO : Output directory: .\moon_P_dem
INFO : Reference image: C:\Users\Ordinateur\Desktop\fits_flipped\ldem_1024_75s_60s_000_015.fits
INFO : Set default target => -172.49951 -67.50049 15.0
INFO : BITPIX found in the reference image => 16
INFO : Data range [-8344 .. 5886] (estimation), pixel cut [-4507 .. 2163]
*WARN*: Uncompatible tileOrder=8 compared to default pre-existing survey tileOrder=9
*ERROR: Uncompatible pre-existing HiPS survey
That was my first issue, but I have another one. This one relates to how HipsGen manages latitude and longitude.
When visualising the 512x512 tiles on the index.html file generated at the end of the jar command, something strange happens.
For example, a TIF image containing data from latitudes between -60° and -45° ends up being displayed as between 45° and 60°. This happens for all my data. Also, the longitude is reversed; instead of going from left to right, it goes from right to left.
To check my results, I use the following website to see if my rendering is similar.
https://alasky.cds.unistra.fr/Planets/CDS_P_Moon_LROC-WAC-100m/
I saw that TIF images should be flipped along the Y-axis before conversion to FITS, because the origin is at the top-left corner in GDAL, but at the bottom-left corner in Hips. To avoid altering the data by flipping them in the Y-axis, I modified the header of the FITS file as follow:
header[‘CDELT2’] = -header[‘CDELT2’] # Flip Y
header[‘PC2_2’] = -header.get(‘PC2_2’, 1.0)
header[‘CRPIX2’] = naxis2 - header[‘CRPIX2’] + 1
This was necessary because changing the data did not work — the latitude was still reversed — but modifying the header made it work.