New nasadata R package
This package intends to provide a hassle-free way to access some of NASA’s open-source API’s to build applications or models.
Because the documentation seems inconsistent and there are tons of API’s, I have concentrated my efforts on three which I believe provide the best “bang for my money”.
The source package is built around these three API’s, but for the sake of clarity, i’ll group the first two into one example.
The Earth Observatory Natural Event Tracker is a Webservice that feeds curated natural “events” that are tracked by a few sources. It is somewhat unclear what exactly constitutes an “event”…
From the official docs:
The curation of events is a big component of the EONET system and while the technical details are, to an extent, straight forward, the definition of what exactly constitutes an event is fluid and daring us to be constrained. What are the contextual parameters of an event? If one curator defines a specific wildfire in Idaho as a discrete event and another defines the summer wildfire season in the Pacific Northwest as a single event, what does that mean for the end user? If an end user can filter by source/curator does that provide them with ample context for the development of their application?
We are still thinking about these issues and how to best represent them within EONET and we encourage you to get in touch with us if you have ideas or suggestions or use cases that you have developed.
However, at least this gives us an idea. An event is something like a storm, fire, drought, etc.
So, let’s imagine we want to see some action that occured a few days ago.
I’ll start with installing the package:
Now, what kind of event do I want? We can query the webservice to find all of the available ones like this:
Who is reporting these events is probably also important, so we can see this with a similar function:
Now that we got this out of the way, let’s see if we can get an individual event. The
earth_event() function does this in an intuitive way. I’m going to bring only the latest event reported by InciWeb:
The event is a list with a few objects parsed together:
- Events: Gives us an overview of each event(s) in a data.frame. This includes id, title, description, link.
- Sources: Tells us the sources by event id in a data.frame.
- Categories: Categories by event id (also in a data.frame).
- Geography: Gives us the coordinates or polygon where the event took place. This can be a list with lists. For example, if there are several coordinates and times (if it is an event that was prolonged or moved, like a hurricane).
- Meta: Some metadata related to the query, including the string used.
In this case, we have a fire in North Carolina…
And this is where it happened…
The coordinates are of course useful because we plot the events in our favorite R package (leaflet or ggmap is really nice) or we can also use it to “feed” into the other API’s in the package. I’ll explain these next…
Imagery and Assets API’s
The Earth Imagery API (available here) let’s us access imagery that is being retrieved from Landsat 8 Satellites and stored in Google Earth Engine. From what I can see, the images are poor quality but the obvious point here is to merge them and detect large variations (for example, to track deforestation).
The Assets API is basically a helper for the Imagery API: it gives us dates of available coordinates, so that we can query the latter and retrieve the image.
Let’s see if we can see the “event” we recorded earlier…
First, I want to see if there is any images recorded in that time frame (the frecuency is roughly every 16 days).
Caveat: This API requieres an active key. It’s free and you can get it at api.nasa.gov
So, it seems we’re out of luck… The fire ocurred after the last picture taken. Nonetheless, let’s see how we can download this last image…
img object is a list consisting of two objects:
- image_data: Information about the image (date, url, cloud_score (if parameter is set to TRUE), id)
- image_png: Matrix representation of the image (obtained via
If the parameter is set to TRUE, you also get a rasterImage, in this case, this one…
This package is still in the early stages of development, and I plan on submitting to CRAN in a few weeks, so any suggestions/improvements are very welcome at my twitter: @eflores89 or via issues in the github package repo: https://github.com/Eflores89/nasadata.