I know this has been asked before, but none of the suggested solutions works for me, and Converting Sentinel-3 data (netcdf) to GeoTIFF is for Java. I tried the accepted answer from Map project a raster having separate latitude and longitude raster bands, but got the error message
ERROR 1: Unable to compute a transformation between pixel/line and georeferenced coordinates for Oa01_radiance.tif. There is no affine transformation and no GCPs.
although I made sure that my
longitude.vrt have the same dimensions as
Oa01_radiance.vrt and also point to the correct files.
So I have some Sentinel-3 data, which come as a folder of a number of NetCDF's, one per radiance band, together with another NetCDF holding tie points for every x-th pixel (every 64th, in that case). I managed to interpolate the lats and lons and create single tifs with the same dimensions as the radiance bands, so basically the lat/lon information for each pixel (I checked them, they are correct). From the other questions around the web, I tried this:
# create vrt for data, lat and lon gdal_translate -of VRT lat.tif latitude.vrt gdal_translate -of VRT lon.tif longitude.vrt gdal_translate -of VRT NETCDF:"Oa01_radiance.nc" Oa01_radiance.vrt
Then I edited
data.vrt to only contain the following:
<VRTDataset rasterXSize="4865" rasterYSize="4091"> <metadata domain="GEOLOCATION"> <mdi key="X_DATASET">MY_FILE_PATH\longitude.vrt</mdi> <mdi key="X_BAND">1</mdi> <mdi key="Y_DATASET">MY_FILE_PATH\latitude.vrt</mdi> <mdi key="Y_BAND">1</mdi> <mdi key="PIXEL_OFFSET">0</mdi> <mdi key="LINE_OFFSET">0</mdi> <mdi key="PIXEL_STEP">1</mdi> <mdi key="LINE_STEP">1</mdi> </metadata> <VRTRasterBand dataType="Float32" band="1"> <SimpleSource> <SourceFilename relativeToVRT="0">NETCDF:Oa01_radiance.nc</SourceFilename> <SourceBand>1</SourceBand> <SourceProperties RasterXSize="4865" RasterYSize="4091" DataType="Float32" BlockXSize="4865" BlockYSize="1" /> <SrcRect xOff="0" yOff="0" xSize="4865" ySize="4091" /> <DstRect xOff="0" yOff="0" xSize="4865" ySize="4091" /> </SimpleSource> </VRTRasterBand> </VRTDataset>
and then tried
gdalwarp -geoloc -t_srs epsg:4326 Oa01_radiance.vrt Oa01_radiance.tif
which resulted in the above mentioned error. So
- is there something I'm missing and
- is there some Python code that can convert the data from the given structure to GeoTiff?
One more comment: using min/max of the lat/lon bands (even the interpolated ones) and calculating the GeoTransformObject from them results in unacceptable offsets and distortions of several hundred km.