How to Get Polar Ice Data from NASA’s ICESat-2 Satellite with Code

Proto Bioengineering
7 min readMar 20, 2023

--

See how Earth’s North and South Poles are doing with Python, R, or Bash.

Image of the ice measurement data collected by the National Snow and Ice Data Center.

NASA has two satellites that track the levels of ice and vegetation of the North and South Poles of the earth: ICESat and ICESat-2. The first ICESat was launched in 2003, and ICESat-2, which captures at least 250 times as much detail, was launched in 2018.

We will use the Open Altimetry API and some code to get data from ICESat-2 to see how the poles are doing. This data will tell us about the elevation of ice, land, and vegetation (e.g. forest canopies) around the poles.

How ICESat-2 Works

ICESat-2 uses LIDAR (which police also use to catch you speeding) to measure the elevation of all of the land and ice near the North and South Poles.

LIDAR is also used for non-citizen-ticketing activities like surveying. Photo by Scott Blake on Unsplash

It uses 6 different lasers in a system called ATLAS, which takes a measurement of the Earth every 28 inches, or 10,000 times a second. ICESat-2 is indeed a space laser. (No, it does not cause wildfires.)

“ICESat-2… describe[s] elevations of sea ice, land ice, forest canopies, water height, urban areas, and more.” (NSIDC, 2023)

Our Data Source: Open Altimetry

We’re going to get ICESat-2 data from Open Altimetry, which is an open data platform made specifically for providing ICESat data.

To play around with the data online, you can check out the ICESat-2 map here.

The ICESat-2 map online at OpenAltimetry.org.

Getting ICESat-2 Data: the API URL

This is the trickiest part, but after this, we only have to write about 5 lines of code.

To get the data, we have to build a URL on the Open Altimetry API documentation page and then use that URL in a short Python, R, or Bash script.

The API’s base URL is:

https://openaltimetry.org/data/api/icesat2/

But we have to add a bunch of parameters after that to specify which data we want, such as the date the data was collected, which dataset specifically, and which of the 6 laser beams we want data from (or all 6 at once).

We’ll end up with a URL like:

https://openaltimetry.org/data/api/icesat2/atl03?date=2020-05-13
&miny=11.88&maxy=12.337&minx=12.59&maxx=13.227&beamName=gt1l&trackId=732
&client=portal&outputFormat=json

This is just the base URL with the parameters added (our data choices). All of the stuff on the end, like date=2020–05–13 and beamName=gt1l, tells Open Altimetry about the specific part of the data that we want. Data has been collected at 10,000 points per second since 2018, so we use these parameters to narrow it down. At the end of the URL, we also tell the API that we want the data in JSON format with outputFormat=json.

Putting all of these parameters in the URL makes it so that our eventual Python, R, or Bash code is only a few lines long.

Let’s build the URL.

To generate your Open Altimetry API URL, go to the API documentation webpage.

Above is a list of the endpoints (for example: /icesat2/atl03). Each endpoint “houses” a particular type of ICESat-2 data. The first is photon data, the second is Land Ice Height data, the third is Sea Ice Height data, and so on. We’ll specify one of these endpoints in our final API URL.

Decide on which type of data you want. For this example, we’ll get Sea Ice Height data (row 3 above, which is from the ATL07 dataset and is at endpoint /icesat2/atl07). Descriptions of all of the datasets above are available from NASA.

To get the Sea Ice Height data URL, we’ll click the dropdown arrow on the far right, then click Try it out on the right.

We’ll see a bunch of options and text fields drop down.

These are all of the parameter options that get tacked onto the end of the API URL and tell Open Altimetry which data we want. We will use the default parameters.

Open Altimetry’s API documentation is user-friendly, since it lets you type in your choices and builds the URL for you. Not all APIs are this way.

Scroll down to the big blue Execute button. If you don’t see it, make sure you clicked the Try it out button in the top right corner of the dropdown.

After clicking Execute, our final API URL (the second black box labeled Request URL) will pop up below. We can use this URL in our code to get ICESat-2 data.

Getting ICESat-2 Data with Bash

This is the easiest version of the 3 languages, because the URL generator above gives us a curl command (the first black box), which is actually a Bash command. All we have to do is copy and paste the curl statement into the command line and run it. (That’s Terminal on Mac and Command Prompt on Windows).

curl -X 'GET' \
'https://openaltimetry.org/data/api/icesat2/atl07?date=2020-05-13&minx=-88&miny=56&maxx=-86&maxy=58&trackId=736&client=portal&outputFormat=json' \
-H 'accept: */*'

When run on the command line, this looks like:

The curl command run in Terminal on a MacBook.

And the results are thousands of lines of polar ice elevation data:

You can add a filename to the end of the curl command to save the data. We’ll add > icesat-2.json to the command to save the data to a JSON file.

The full command with filesaving is:

curl -X 'GET' \
'https://openaltimetry.org/data/api/icesat2/atl07?date=2020-05-13&minx=-88&miny=56&maxx=-86&maxy=58&trackId=736&client=portal&outputFormat=json' \
-H 'accept: */*' \
> icesat-2.json

Getting ICESat-2 Data with Python

The difficult part is over. Now, we just need to plug the URL in to a few lines of Python code (or R code, which is covered in the next section).

The full Python script is:

import requests

open_altimetry_api = "https://openaltimetry.org/data/api/icesat2/atl07" + \
"?date=2020-05-13&minx=-88&miny=56&maxx=-86&maxy=" + \
"58&trackId=736&client=portal&outputFormat=json"
icesat_2_data = requests.get(open_altimetry_api)

print(icesat_2_data.json())

The line breaks (+ \) aren’t necessary but are there for readability.

This will get us a similar result as above, thousands of lines of elevation measurements in JSON format.

Getting ICESat-2 Data with R

Getting the data with R is similar to Python. We just need to plug in the API URL to an R script or RStudio using an HTTP library then get the JSON data from the API’s response.

The full R script is:

install.packages("httr")
library(httr)

open_altimetry_api <- "https://openaltimetry.org/data/api/icesat2/atl07?date=2020-05-13&minx=-88&miny=56&maxx=-86&maxy=58&trackId=736&client=portal&outputFormat=json"
response <- VERB("GET", open_altimetry_api)

icesat_2_data <- content(response, "text")
icesat_2_data

Above, we:

  • install and import R’s HTTP library (httr)
  • reach out to the Open Altimetry API with httr’s VERB(“GET”) function
  • extract and print the ICESat-2 data that we got back

You can read more about Httr’s VERB function here.

In RStudio, this looks like:

And a crapton of Sea Ice Height data gets printed from icesat_2_data.

That is how you get data about Earth’s polar ice caps from Open Altimetry and NASA.

Now What? (Project Ideas)

A handful of scientific publications are listed on Open Altimetry’s website, such as:

  • Rapid Visualization and Analysis of ICESat-2 Data using an Intuitive GUI and JupyterHub Notebooks (Khalsa et al., 2019)
  • Advanced Discovery, Visualization, and Access of the Cryosphere’s Changing Surface Height from NASA’s ICESat-2 Mission Using the OpenAltimetry Platform (Steiker et al., 2019)

You could use the ICESat or ICESat-2 datasets to study the change in Earth’s polar ice over time. There are also opportunities to study the ecology and biology of the different forest canopies by their elevation. Or maybe you could look at the change in ice coverage and thickness or the difference between the height of the ice and the water surrounding it (the Sea Ice Freeboard dataset, ATL10). The state of the ice on Earth’s poles can tell us a lot about the past, present, and future of our planet.

For more datasets on Earth and space, check out NASA’s API list or the US Geological Survey’s APIs.

Questions and Feedback

If you have questions or feedback, email us at protobioengineering@gmail.com or message us on Instagram (@protobioengineering).

If you liked this article, consider supporting us by donating a coffee.

Related Articles

--

--

Proto Bioengineering

Learn to code for science. “Everything simple is false. Everything complex is unusable.” — Paul Valery