Convert Ascii to netcdf
Added by s r over 3 years ago
Hello,
I have a ascii file, in a 1 km regular grid (1081*1171-EPSG:27572), gridfile description below :
gridtype = lonlat
xsize = 1081
ysize = 1171
xfirst = 39500
xinc = 1000
yfirst = 1604500
yinc = 1000
I'm trying to convert this file to a gridded netcdf file with :cdo -f nc -settaxis,2020-04-01,00:00:00,1day -setctomiss,-9999.0 -setname,prtot -input,gridfile_description.txt Test_pr.nc < Test_pr.asc
Regridding of netcdf file is wrong, compared to the original grid and missing values. Could you indicate how to convert this ascii file with cdo ?
Many thanks
Test_pr.asc (8.06 MB) Test_pr.asc | ascii file test | ||
gridfile_description.txt (109 Bytes) gridfile_description.txt | gridfile desciption |
Replies (4)
RE: Convert Ascii to netcdf - Added by Brendan DeTracey over 3 years ago
Hi. This question gets asked a lot. Have you searched the forums for possible answers?
RE: Convert Ascii to netcdf - Added by s r over 3 years ago
Hello Brendan,
Yes, I found many subjects on the forum but no answer, nor in the online documentation. Particulary how to correctly create the gridfile description.
thanks,
RE: Convert Ascii to netcdf - Added by Karin Meier-Fleischer over 3 years ago
Hi S,
choosing the PROJ.4 settings from the description of the EPSG:2752 projection https://epsg.io/27572 and modifying the grid description file I got an netCDF file which seems to be close but not correct.
By the way rows = y and cols = x, so your xsize and ysize had to be exchanged.
You have to take care about the settings by yourself.
gridfile.txt:
gridtype = projection gridsize = 1265851 xsize = 1171 ysize = 1081 xfirst = 39500 xinc = 1000 xunits = "m" yfirst = 1604500 yinc = 1000 yunits = "m" grid_mapping = crs grid_mapping_name = lambert_conformal_conic proj_params = "+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs"
Convert to projected grid in netCDF format:
cdo -f nc -settaxis,2020-04-01,00:00:00,1day -setctomiss,-9999.0 -setname,prtot -input,gridfile.txt out.nc < Test_pr_2.asc
Remap to regular lonlat:
cdo -remapbil,r3600x1800 out.nc out_remapped.nc
Now, its on you to find the correct settings.
-Karin
RE: Convert Ascii to netcdf - Added by s r over 3 years ago
Hello Karin,
Many thanks for the gridfile description. yfirst and yinc parameters have to be changed (yfirst=ymax, yinc=-yinc). It's ok now with this configuration.