Skip to content

Glacier Mass Change Algorithm

audreykling edited this page Feb 24, 2023 · 15 revisions

Receiving Data from NASA’s Global Precipitation Measurement System (GPM):

In order to get snowfall data for a specific glacier, we send a call to the GPM API with the date, latitude and longitude of the glacier, and type of precipitation (in this case, precip_30mn_frozen). Data is returned in the form of a JSON file, from which we can extract a GeoTIFF file that contains the precipitation accumulation visualized within the area.

GeoTIFF files are an extension of TIFF files (which stands for Tagged Image File Format). Like TIFF, GeoTIFF is a raster graphic file type, only GeoTIFF makes use of TIFF layers in order to store geological metadata alongside the raw data. As a result, GeoTIFF files tend to be large, but they’re an effectively “lossless” way of compressing and sending data, and all information is contained within one file.

Retrieving API Data via Postman

Postman is an API platform that allows us to access and visualize Nasa’s GPM Data. In Postman, you can create a collection to store the commands/requests you have made to the API. In your collection, there is a bar which allows you to insert the API link and interact with the API. We are using the “get” command to retrieve data from the GPM API. Postman also allows you to input query parameters to specify the data you are asking the API for. In regards to the GPM API data, we use the parameters:

  • q = precip_30mn
  • lat = [insert value here]
  • long = [insert value here]
  • startTime = [insert date here]
  • endTime = [insert date here] For more information on these parameters, see the GPM API Documentation page.

From Postman, the GPM API gives us a JSON file, which contains links to the precipitation data in several forms under the “items” section. We are interested in the link for the GeoTIFF file format.

Retrieving Data in R using the HTTR Package

HTTR is a package for R that allows us to access data from the http protocol in R. HTTR can be used for “get” requests to API, similar to “get” requests in Postman. Potential requests in R using HTTR can be visualized in Postman.

To “get” request using HTTR:

dat <- GET (“https:[insert API access link here]”, query = list ([insert query parameters here]))

The API access link can be found in the API’s documentation. For the GPM API, we use "https://pmmpublisher.pps.eosdis.nasa.gov/opensearch". The query parameters specify the data you are requesting from the API. See the Postman Wiki information above for more information.

To check if the “get” request was successful:

  • warn_for_status(dat)
  • stop_for_status(dat)

Warn for status will throw a warning that the request was not successful. Stop for status will terminate the program if the request was not successful.

To visualize in a clean format what our API data contains in R (JSON files only):

str(content(dat, "parsed"))

To visualize what our API data looks like in R (messy format, does not have to be a JSON file):

content(dat)

Analyze GeoTIFF files using GDAL

GDAL is a package for multiple programming languages that can interpret GeoTIFF files. Currently, we are using GDAL in R to open GeoTIFF files and show its content. GDAL also contains methods to interpret and analyze GeoTIFF data.

To install GDAL for R:

install(“rgdal”)

To install GDAL for Python:

https://gdal.org/download.html

Clone this wiki locally