trying to use wget with opendap URL

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
sbenson
Posts: 2
Joined: Mon Aug 17, 2026 5:08 pm America/New_York
Answers: 0

trying to use wget with opendap URL

by sbenson » Mon Aug 17, 2026 5:12 pm America/New_York

Hi,
Does anyone know why this isn't working? I get an empty merra.cdf file with 0 bytes.
wget -q -O merra.cdf "https://opendap.earthdata.nasa.gov/collections/C1276812851-GES_DISC/granules/M2T1NXRAD.5.12.4%3AMERRA2_400.tavg1_2d_rad_Nx.20180101.nc4.dap.nc4?dap4.ce=/SWTDN[0][94][524];/ALBEDO[0][94][524]"

I copied the raw Data URL from this page:
https://opendap.earthdata.nasa.gov/collections/C1276812851-GES_DISC/granules/M2T1NXRAD.5.12.4%3AMERRA2_400.tavg1_2d_rad_Nx.20180101.nc4.dmr.html

Filters:

GES DISC - alouise517
User Services
User Services
Posts: 18
Joined: Thu Dec 18, 2025 4:38 pm America/New_York
Answers: 1

Re: trying to use wget with opendap URL

by GES DISC - alouise517 » Wed Aug 19, 2026 2:44 pm America/New_York

Dear User,

The raw data url is most compatible when used in an internet browser. Please try using the "Copy encoded Data URL" option when using wget, curl, or any other command line tool.

For example here's the encoded data url for your request:
https://opendap.earthdata.nasa.gov/collections/C1276812851-GES_DISC/granules/M2T1NXRAD.5.12.4%253AMERRA2_400.tavg1_2d_rad_Nx.20180101.nc4.dap.nc4?dap4.ce=/SWTDN%5B0%5D%5B94%5D%5B524%5D;/ALBEDO%5B0%5D%5B94%5D%5B524%5D

We would recommend also using an Earthdata Token as described in the following documentation to avoid any issues with authentication when downloading data:

https://disc.gsfc.nasa.gov/information/howto?title=How%20to%20Access%20GES%20DISC%20Data%20Using%20wget%20and%20curl

Please give the following example a try, it should work as desired and save as a ~26kb .cdf file:

wget --header "Authorization: Bearer <token>" "https://opendap.earthdata.nasa.gov/collections/C1276812851-GES_DISC/granules/M2T1NXRAD.5.12.4%253AMERRA2_400.tavg1_2d_rad_Nx.20180101.nc4.dap.nc4?dap4.ce=/SWTDN%5B0%5D%5B94%5D%5B524%5D;/ALBEDO%5B0%5D%5B94%5D%5B524%5D" -O merra.cdf

Where <token> is your Earthdata Token from https://urs.earthdata.nasa.gov/ -> generate token.

Please note that data downloaded are in NetCDF-4 (.nc4) format even though the specified output file type you have included is a .cdf (Common Data Format).

If you have any other questions or require further assistance, please let us know.

Regards,
GES DISC User Services

sbenson
Posts: 2
Joined: Mon Aug 17, 2026 5:08 pm America/New_York
Answers: 0

Re: trying to use wget with opendap URL

by sbenson » Thu Aug 20, 2026 11:22 am America/New_York

Thank you. That is very helpful. I have a .netrc file in my home directory with my earthdata login information. Is it better to use the "Token" instead of the .netrc for authorization?
Thanks,
Sally

GES DISC - alouise517
User Services
User Services
Posts: 18
Joined: Thu Dec 18, 2025 4:38 pm America/New_York
Answers: 1

Re: trying to use wget with opendap URL

by GES DISC - alouise517 » Fri Aug 21, 2026 2:35 pm America/New_York

Hi Sally,

We would recommend using the EDL Token method we described, as it would work more universally with NASA's enterprise-level, Harmony data services.

Thanks, and please let us know if this helps or if you need further guidance.

Regards,
GES DISC User Services

Post Reply