I need to georeference and subset a lot of Sentinel-3-Syn-2-Files. Every data product provides seperate NetCDF-Files for each band and the actual (irregular) coordinate grid called 'geolocation'. So the basic structure is like in the question here. And like the suggested answer I tried it with:
gdal_translate -of XYZ NETCDF:"geolocation.nc":lat latitude.csv
gdal_translate -of XYZ NETCDF:"geolocation.nc":lon longitude.csv
gdal_translate -of XYZ NETCDF:"Syn_Oa17_reflectance.nc":SDR_Oa17 sdr_oa17.csv
paste longitude.csv latitude.csv sdr_oa17.csv|gawk '{print($3/1000000,$6/1000000,$9)}' >merged.csv
I don't know exactly what the term {print($3/1000000,$6/1000000,$9)}
does but it worked apparently. Despite being the question the suggested answer doesn't provide the step how to actually write the merged data back to e.g. NetCDF. I found something similar here. But when I do:
gdal_translate merged.csv combined.nc
I get:
ERROR 1: Ungridded dataset: At line 4, too many stepY values
There is a workaround for this kind of error. But the suggested step:
tail -n +2 merged.csv| sort -n -t ' ' -k2 -k1 > merged_sorted.xyz
Also provides a dataset which causes the same error:
gdalinfo merged_sorted.xyz
ERROR 1: Ungridded dataset: At line 2, X spacing was -0.038000. Expected >0 value gdalinfo failed - unable to open 'merged_sorted.xyz'.
For the sake of completeness, when I do gdal_translate
I'm getting a warning message:
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
But as it produced the desired csv-files I ingored it. If anyone is interested in the dataset it can be found here. Does anyone know how to do this?