How to convert gridded population Ascii file to Netcdf file
Added by muhammad Shoaib over 3 years ago
Hi everyone,
I have a gridded population file in Ascii format and I need it in nc format. I converted the file with the following CDO command:
cdo -f nc -settaxis,2005-01-01,00:00:00,1day -setname,population -input,gridfile.txt population1.nc < pop.txt
could anyone help me please to check the file that what error it has.
The gridfile.txt as follows
gridtype = lonlat
xsize = 360
ysize = 180
xfirst = 0.0
xinc = 1.0
yfirst = 89.5
yinc = 1.0
whereas I downloaded the Ascii file from https://sedac.ciesin.columbia.edu/data/set/gpw-v4-population-density-rev11/data-download
as I needed a single year gridded population data file.
thank you for the help in advance.
Shoaib
gridfile.txt (95 Bytes) gridfile.txt | grid description file | ||
population1.nc (258 KB) population1.nc | Output file | ||
gpw_v4_population_density_rev11_2005_1_deg.asc (431 KB) gpw_v4_population_density_rev11_2005_1_deg.asc | Ascii file |
Replies (2)
RE: How to convert gridded population Ascii file to Netcdf file - Added by Karin Meier-Fleischer over 3 years ago
Hi Shoaib,
the input file contains 6 header lines which have to be deleted.
Furthermore the gridfile is wrong, the xstart and ystart values are wrong (see header of input file) and the yinc has to be negative.
And last but not least the data contains missing values (see header of input file again).
1. Delete header lines at the top of the input file.
2. Modify the gridfile.txt
gridtype = lonlat gridsize = 64800 xsize = 360 ysize = 180 xname = lon xlongname = longitude xunits = degrees_east xfirst = -180.0 xinc = 1.0 yname = lat ylongname = latitude yunits = degrees_north yname = lat yfirst = 90.0 yinc = -1.0
3. The CDO command has to be
cdo -f nc -settaxis,2005-01-01,00:00:00,1day -setctomiss,-9999 -setname,population -input,gridfile.txt population1_with_missing_values.nc < gpw_v4_population_density_rev11_2005_1_deg.asc
-Karin
RE: How to convert gridded population Ascii file to Netcdf file - Added by muhammad Shoaib over 3 years ago
Thank you karin