Access the Product webpage in the PODAAC
Click Data Access
DIRECT ACCESS
> access HTTPS Link
You have to “Sign In” and Choose ‘sample day’ for get the longitude, latitude information.
Click the Opendap
and set the option like below
NetCDF-4
lat
” and “lon
”Click Get Data
Make new folder for MATLAB Workspace.
Move the nc file in the new folder
(You can change the name of nc file)
Open the new MATLAB script and read the longitude, latitude information of the NC file.
%% read 'lon', 'lat' data from NC file
clc; clear;
fnm = 'sample_lonlat_20020601_MUR_41.nc4';
ncdisp(fnm)
lon = ncread(fnm, 'lon');
lat = ncread(fnm, 'lat');
Find the index of region where you want to download
Spatial_area = [24, 35, 121, 132];
idlat(1) = findnearpoint(lat, Spatial_area(1));
idlat(2) = findnearpoint(lat, Spatial_area(2));
idlon(1) = findnearpoint(lon, Spatial_area(3));
idlon(2) = findnearpoint(lon, Spatial_area(4));
function id = findnearpoint(base, target)
% find nearest point of "target" from "base"
[~, id] = min(abs(base-target));
end
Prepare the period information with proper format
period = [2014, 1, 1; 2014, 1, 5];
period2 = datetime(period);
period3 = period2(1):days(1):period2(2);
Back to the website - Add the Variables (time and variables you want) - Copy raw Data Link
If the url is like this,
https://opendap.earthdata.nasa.gov/providers/POCLOUD/collections/GHRSST Level 4 MUR Global Foundation Sea Surface Temperature Analysis (v4.1)/granules/20020601090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.dap.nc4?dap4.ce=/time[0:1:0];/lat[0:1:17998];/lon[0:1:35999];/analysed_sst[0:1:0][0:1:17998][0:1:35999]
Then, you can split this link into like this
Then, you should change the “2” and “4” in the MATLAB.
The example is like this.
%% load data with URL
% If the downloaded file has the SAME NAME, INCREASE the value of lag_time
lag_time = 3; % seconds between download each files
for loop = 1:length(period3)
period4 = period3(loop); period5 = datevec(period4); period5 = period5(1:3);
period6 = sprintf("%d%02.0f%02.0f", period5);
url1 = "<https://opendap.earthdata.nasa.gov/providers/POCLOUD/collections/>" + ...
"GHRSST%20Level%204%20MUR%20Global%20Foundation%20Sea%20Surface%20Temperature%20Analysis%20(v4.1)" + ...
"/granules/";
url2 = period6;
url3 = "090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1.dap.nc4?dap4.ce=";
url4 = sprintf("/time[0:1:0];/lat[%d:1:%d];/lon[%d:1:%d];/analysed_sst[0:1:0][%d:1:%d][%d:1:%d]", ...
idlat(1)-1, idlat(2)-1, idlon(1)-1, idlon(2)-1, ...
idlat(1)-1, idlat(2)-1, idlon(1)-1, idlon(2)-1);
url5 = strcat(url1, url2, url3, url4);
web(url5)
pause(lag_time);
end
Finally, you can automatically download the data!