Downloading CO2 data from NASA GES DISC

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
EarthdataForumContributor
Posts: 284
Joined: Thu Jul 11, 2019 4:32 pm America/New_York
Answers: 3

Downloading CO2 data from NASA GES DISC

by EarthdataForumContributor » Wed Apr 20, 2022 1:40 pm America/New_York

User-submitted question:

"I am working on a research project. For that I need some of the CO2 data which is available on the website.
I am having difficulty in understanding how to download it. At the moment, I marked the region and also selected
the years which I needed the data for, but at the end how to download it, because it is just creating a lot of files
and it is showing the instruction for download to install the wget and windows+r function but I am not understanding it properly, can you please help me with this?

I am attaching the image so you can have a better look for what I am trying to say. I have a windows PC and I also
downloaded wget."
screenshot of CO2 data download Khalique.png
screenshot of CO2 data download Khalique.png (476.33 KiB) Not viewed yet

Tags:

GES DISC - jimacker
User Services
User Services
Posts: 299
Joined: Mon Sep 30, 2019 1:57 pm America/New_York
Answers: 3
Has thanked: 2 times
Been thanked: 4 times

Re: Downloading CO2 data from NASA GES DISC

by GES DISC - jimacker » Wed Apr 20, 2022 1:47 pm America/New_York

From your post, it is clear you were able to regionally and temporally subset the data for your research. Below
are some quick commands for using wget on Windows to help download several files. These commands use the user’s Earthdata account information for downloading the datasets.

wget for Windows

Downloading one file:

wget --load-cookies C:\.urs_cookies --save-cookies C:\.urs_cookies
--auth-no-challenge=on --keep-session-cookies --user=<your username>
--ask-password <url>

Downloading multiple files:

wget --load-cookies C:\.urs_cookies --save-cookies C:\.urs_cookies
--auth-no-challenge=on --keep-session-cookies --user=<your username>
--ask-password -i <url.txt>

More information is available at this link:
https://disc.gsfc.nasa.gov/data-access#windows_wget

lukasz.borowski
Posts: 2
Joined: Mon Feb 26, 2024 8:22 am America/New_York
Answers: 0

Re: Downloading CO2 data from NASA GES DISC

by lukasz.borowski » Mon Feb 26, 2024 8:37 am America/New_York

Hi

Is there a code for Python (on Windows) on how to download such files? I tried to follow https://disc.gsfc.nasa.gov/information/howto?title=How%20to%20Access%20GES%20DISC%20Data%20Using%20Python but I, unfortunately, lost with the requests library.

The file is:
'https://data.gesdisc.earthdata.nasa.gov/data/OCO2_DATA/OCO2_L2_Standard.11r/2014/249/oco2_L2StdND_00964a_140906_B11006r_230325051042.h5'.

By requests.get() I may log in to "https://data.gesdisc.earthdata.nasa.gov/" (status 200) and then what I shall do next?

Lukasz

cbattisto
Posts: 11
Joined: Wed Feb 16, 2022 4:38 pm America/New_York
Answers: 0

Re: Downloading CO2 data from NASA GES DISC

by cbattisto » Wed Mar 20, 2024 12:02 pm America/New_York

Hello,

You can simply pass the URL of the granule that you wish to access into the requests.get() function, but that must be stored into a variable to be written to a file, like so:

import requests

# URL of the file to be downloaded
url = "https://data.gesdisc.earthdata.nasa.gov/data/OCO2_DATA/OCO2_L2_Standard.11r/2014/249/oco2_L2StdND_00964a_140906_B11006r_230325051042.h5"

# Perform the GET request
response = requests.get(url)

filename = url.split('/')[-1] # Extracts the file name from the URL
with open(filename, 'wb') as file:
file.write(response.content)

lukasz.borowski
Posts: 2
Joined: Mon Feb 26, 2024 8:22 am America/New_York
Answers: 0

Re: Downloading CO2 data from NASA GES DISC

by lukasz.borowski » Thu Mar 21, 2024 5:15 am America/New_York

Thank you.
ŁB

Post Reply