I need a python code, to convert CSR GRACE and GRACE Mascon (NetCDF format) to CSV or GeoTiff format. I tried but ran into few troubles. Help will be appreciated.
It would be useful to describe your 'troubles' in some detail. Otherwise there is practically hundreds of things that might be going wrong. Does it work using GDAL?
Please see this link which uses xarray and rioxarray (a RasterIO extension for xarray) to convert a NetCDF file to GeoTiff format. This is done entirely using Python. https://pratiman-91.github.io/2020/08/01/NetCDF-to-GeoTIFF-using-Python.html
Qasim Khan thank you for the clarification. I have provided a link to a Google Colab page which will produce a GeoTiff file with time-series layers when used with a GRACE .nc file. I also have supplied the .py version here in case the link is broken in the future.
Qasim Khan You are welcome, I am glad you were able to test. Please try this code which solves the problem of displaying the different time values for each band. The times are specified as they are in the data file, as decimal values. If you require a particular datetime format (i.e. yyyy-mm-dd), you will have to modify the times variable so that the decimal values (days since the data start date) are converted.
Qasim Khan I think this should be what you need. I've updated the Google Colab notebook link from earlier and attached the code as a .py file below. The start date will need to be entered manually one time, then all the dates will resolve accordingly as band names.
why do not give it try in R? it is more easy in R than python. furthermore, the solution provided here, is complex about GRACE data as GRACE data has missing months. So be careful giving wrong names to data