Skip to content

Instantly share code, notes, and snippets.

@sh0rtwave
Last active November 18, 2015 21:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sh0rtwave/29773181164ef748cc64 to your computer and use it in GitHub Desktop.
Save sh0rtwave/29773181164ef748cc64 to your computer and use it in GitHub Desktop.
EPIC Daily 'Blue Marble' API for epic.gsfc.nasa.gov
# EPIC Daily “Blue Marble” API
The API URL is: http://epic.gsfc.nasa.gov/api/images.php
This gets you a list of the latest day’s images & metadata.
OR
http://epic.gsfc.nasa.gov/api/images.php?date=YYYY-M-D&w=X&e=Y
The second form’s optional parameters allow you to focus in to geographical regions that were in view (technically, longitudinal bounding points) on a given date.
For instance: Using North America’s boundaries of east = -53.034, and west = -170.859 and choosing August 24, 2015, the URL would look like this:
http://epic.gsfc.nasa.gov/api/images.php?date=2015-8-24&w=--170.859&e=-53.034
The date parameter is unpadded(e.g. 2015-9-1, vs. 2015-09-01 for September 1, 2015), and optional. Leaving the date off will default to the latest image set.
Leaving out the coordinates gets you every image for whatever date is returned.
Adding either longitudinal parameter returns all images for the given date, for which the supplied longitude is in view of the camera.
* * *
## Getting the data -
### Fetching from PHP:
<?php
$data_url = 'http://epic.gsfc.nasa.gov/api/images.php'; // modify the URL as needed for filtering, unmodified gets you the latest
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$imageDataArray = json_decode(curl_exec($ch));
?>
### Fetching from jQuery:
$.ajax('http://epic.gsfc.nasa.gov/api/images.php',
{
success : function(iDataArr, stat, xhr) {
// do something with the list
}
});
## JSON data reference
### ImageData object:
{
"image": "epic_1b_20150826231708_00", // image name sans extension.
"caption": "About an image", // Will contain a caption
"coords": “{}", // Contains a JSON string representing a Coordinates object.
"date": "2015-08-26 23:17:08" // The date the capture sequence for the data was initiated
}
ImageData notes:
For the image field to be useful, it has to be added to a URL. Image URLs differ depending upon purpose.
Given an image name of “epic_1b_20150901205648_00” (taken Sept 1, 2015, with the camera aimed at 3 storms in the pacific (my favorite)), we have URLs as follows:
For compressed JPG thumbnails, the URL would be:
http://epic.gsfc.nasa.gov/epic-archive/thumbs/epic_1b_20150901205648_00.jpg
For full-size, compressed JPG previews, the URL would be:
http://epic.gsfc.nasa.gov/epic-archive/jpg/epic_1b_20150901205648_00.jpg
For full-size original PNG images with full metadata in the comments, the URL would be:
http://epic.gsfc.nasa.gov/epic-archive/png/epic_1b_20150901205648_00.png
### Coordinates object
{
"centroid_coordinates": { // Geographical coordinates that the satellite is looking at
"lat": 4.076132,
"lon": -169.648562
},
"dscovr_j2000_position": { // Position of the satellite in space
"x": -1439710.750000,
"y": 659227.437500,
"z": 113316.414062
},
"lunar_j2000_position": { // Position of the moon in space
"x": 153199.062500,
"y": -319797.531250,
"z": -104905.093750
},
"sun_j2000_position": { // Position of the sun in space
"x": -134918656.000000,
"y": 62555808.000000,
"z": 27119770.000000
},
"attitude_quaternions": { // Satellite attitude
"q0": 0.976360,
"q1": -0.212080,
"q2": -0.039540,
"q3": 0.013750
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment