How to process NC file in matlab
Show older comments
I've monthly soil monisture NC file. This file contains monthly soil monisture data since 1948. I want to extract soil data within my shapefile in text file (Shapefile has also attached). I google alot to proccess NetCDF file in matlab find not solution, The ncdisp of my nc file is given below:
Format:
netcdf4_classic
Global Attributes:
_NCProperties = 'version=1|netcdflibversion=4.4.1.1|hdf5libversion=1.10.1'
Conventions = 'CF-1.0'
title = 'CPC Soil Moisture'
institution = 'NOAA/ESRL PSD'
dataset_title = 'CPC Soil Moisture'
history = 'Wed Oct 18 15:13:37 2017: ncks -d time,,-2 soilw.mon.mean.x.nc soilw.mon.mean.xx.nc
Wed Oct 18 15:12:08 2017: ncks -d time,,-3 soilw.mon.mean.nc soilw.mon.mean.x.nc
CPC Soil Moisture
Obtained on Nov 2004 from CPC's website
and written to netCDF by Cathy Smith 12/2004.
he CPC Global monthly soil moisture dataset is a 1/2 degree resolution grid from 1948 to the present.
The file is written in COARDS and CF compliant netCDF at NOAA ESRL/PSD https://www.esrl.noaa.gov/psd/
Converted to chunked, deflated non-packed NetCDF4 Jul 2014'
NCO = '4.6.9'
References = 'https://www.psl.noaa.gov/data/gridded/data.cpcsoil.html'
Dimensions:
lat = 360
lon = 720
time = 886 (UNLIMITED)
Variables:
lat
Size: 360x1
Dimensions: lat
Datatype: single
Attributes:
long_name = 'Latitude'
units = 'degrees_north'
actual_range = [8.98e+01 -8.98e+01]
standard_name = 'latitude'
axis = 'Y'
coordinate_defines = 'point'
lon
Size: 720x1
Dimensions: lon
Datatype: single
Attributes:
long_name = 'Longitude'
units = 'degrees_east'
actual_range = [2.50e-01 3.60e+02]
standard_name = 'longitude'
axis = 'X'
coordinate_defines = 'point'
soilw
Size: 720x360x886
Dimensions: lon,lat,time
Datatype: single
Attributes:
long_name = 'Model-Calculated Monthly Mean Soil Moisture'
missing_value = -9.97e+36
units = 'mm'
valid_range = [0.00e+00 1.00e+03]
dataset = 'CPC Monthly Soil Moisture'
var_desc = 'Soil Moisture'
level_desc = 'Surface'
statistic = 'Monthly Mean'
parent_stat = 'Other'
standard_name = 'lwe_thickness_of_soil_moisture_content'
cell_methods = 'time: mean (monthly from values)'
actual_range = [0.00e+00 1.00e+30]
time
Size: 886x1
Dimensions: time
Datatype: double
Attributes:
long_name = 'Time'
units = 'days since 1800-01-01 00:00:0.0'
delta_t = '0000-01-00 00:00:00'
avg_period = '0000-01-00 00:00:00'
standard_name = 'time'
axis = 'T'
bounds = 'time_bnds'
coordinate_defines = 'start'
prev_avg_period = '0000-00-01 00:00:00'
actual_range = [5.41e+04 8.10e+04]
I've tied
file='data.nc';
ncdisp(file)
long = ncread(file,'lon');
latt = ncread(file,'lat');
time = ncread(file,'time');
I want output of Soilw in this format in text file
Date Soilw
01/01/2015 10
01/02/2015 20
01/03/2015 0.5
Please help me to convert monthly netcdf datainto text file using matlab please?
7 Comments
Walter Roberson
on 11 Dec 2021
You have Soilw data that is 720 x 360 x 886 where 886 is the number of time instants, covering 1948 to 2021. If I calculate correctly, you have one reading per month
You show some dates on output, but you only show a single scalar for each date. How do you want to summarize 720 x 360 readings into one reading?
Muhammad Usman Saleem
on 12 Dec 2021
You have
720 * 360
over 250,000 different locations, each of which has a soilw for each month.
We can give the dates down the left column, fine -- but for each of those dates you have 259200 different Soilw values. Do you want to output a vector of 259200 different values for each date? Do you want to somehow summarize the different values down to a scalar? Are you given a particular latitude and longitude and the task is to find the nearest point and to give the Soilw values for the point? Are you given a particular latitude and longitude and the task is to interpolate to find the Soilw values for each date based upon the surrounding points (for the case where the given point is not exactly at one of the locations there is a reading for) ?
Muhammad Usman Saleem
on 12 Dec 2021
Muhammad Usman Saleem
on 12 Dec 2021
Walter Roberson
on 12 Dec 2021
I do not seem to find you in my list of customers of my company who have signed 4-Hour Response Time Contracts with us ?
Muhammad Usman Saleem
on 13 Dec 2021
Accepted Answer
More Answers (1)
Categories
Find more on Data Import and Export in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

