write_singlemonth_geotif.py
This Python script is used to convert the JPL GRACE Mascon file from netCDF4 to GeoTIFF format. The most current Mascon dataset can be found and downloaded from https://doi.org/10.5067/TEMSC-3JC62. This script decomposes the multi-year monthly Mascon netCDF file into single GeoTIFF files for each month.
- Inputs: data path and filename (.nc)
- Outputs: output path.
Users need to manually modify the code at line 26 and 27 for the input and output strings. Output filenames are auto created. By default, the script will look in a local 'input' directory (./input/...) and write files to a local output (./output) directory.
update:
input_mascon_file = Path('./input/GRCTellus.JPL.200204_202008.GLO.RL06M.MSCNv02CRI.nc')
output_geotiff_path = Path('./output')
to
input_mascon_file = Path('PATH/TO/YOUR/INPUTFILE')
output_geotiff_path = Path('/PATH/TO/YOUR/OUTPUTFILE')
The code works with both Python 2 and Python 3. The code has been tested on Mac OS and PC (Windows). Required Python libraries are listed below: 1. netCDF - https://unidata.github.io/netcdf4-python/netCDF4/index.html 2. gdal - https://pypi.org/project/GDAL/ 3. pathlib - https://www.python.org/dev/peps/pep-0428/