Package 'nasadata'

Title: Interface to Various NASA API's
Description: Provides functions to access NASA's Earth Imagery and Assets API and the Earth Observatory Natural Event Tracker (EONET) webservice.
Authors: Eduardo Flores, Viliam Simko
Maintainer: Eduardo Flores <[email protected]>
License: CC0
Version: 0.10.0
Built: 2025-03-05 03:01:28 UTC
Source: https://github.com/eflores89/nasadata

Help Index


Call Asset API

Description

Calls NASA's Earth Imagery Assets API and returns data.frame with information on time and location of images between two dates.

Usage

earth_asset(key, lon, lat, start_date, end_date = Sys.Date())

Arguments

key

Key for API authentication.

lon

Longitud of coordinate position.

lat

Latitud of coordinate position.

start_date

Start date to search for image. In YYYY-MM-DD format.

end_date

End date to search for image. In YYYY-MM-DD format. Defaults to current system date.

Value

Returns a data.frame containing the following columns:

date

date of the sample

id

identifier of the sample or "NO RESULTS"

type

type of the sample, currenlty always "Point"

coordinates

latitude and longitude as a string delimited by a space

Examples

## Not run: 
key <- "123key"
img <- earth_asset(key, -100.31008, 25.66779, "2016-01-01")

## End(Not run)

Calls EONET webservice

Description

Calls NASA's Earth Observatory Natural Event Tracker (EONET) webservice and returns a list containing individual events as data.frame.

Usage

earth_event(status = c("all", "open", "closed"), sources = "all",
  category_id = "all", limit = 10, days = 20, LimitType = c("limit",
  "days", "all"), TrySimplify = TRUE)

Arguments

status

Accepts "open" or "closed". Defaults to "all", which includes both.

sources

Accepts character id strings from EONET sources (see eonet_sources)

category_id

Accepts number id strings from EONET category tree (see eonet_categories)

limit

Limit of events to download. If LimitType = "days" this is not considered. Defaults to 10.

days

Limit of days (less than today) to download events from. If LimitType = "limit" this is not considered. Defaults to 20.

LimitType

Type of limit to consider: "limit" (count of events), "days" (days less than today) or "all" (both limits).

TrySimplify

If TRUE tries to coerce category and event data.frames into one (successful if there is one category per event).

Value

Returns a list with individual events:

Events

data.frame - TODO description

Sources

data.frame - TODO description

Categories

data.frame - TODO description

Geography

list of data.frame - TODO description

Meta

data.frame - TODO description

Examples

## Not run: 
event <- earth_event(limit = 1)

## End(Not run)

Fetches image from Earth Imagery API

Description

Calls NASA's Earth Imagery API and returns list with identification information and image.

Usage

earth_image(key, lon, lat, date, cloud_score = TRUE, plot = FALSE,
  meta_only = FALSE)

Arguments

key

API Key for authentication.

lon

Longitude of coordinate position.

lat

Latitude of coordinate position.

date

In YYYY-MM-DD format. The API wil return the image that is closest to this date.

cloud_score

Gives a score of percentage of cloud cover, via algorithm (see official documentation). Defaults to TRUE.

plot

If TRUE will plot the image via generic plot function.

meta_only

If TRUE will only download the meta data for the image.

Value

Returns a list of two elements:

image_metadata

This contains a data.frame

image_raster_data

This contains an array representing a raster

Examples

## Not run: 
key <- "123key"
img <- earth_image(key, -100.31008, 25.66779, "2016-01-01")

## End(Not run)

Calls EONET category webservice.

Description

Calls NASA's EONET Webservice and returns all categories available.

Usage

eonet_categories()

Value

Returns data.frame with 5 columns:

id

Unique id (can be used to filter earth_event)

title

Title of category

link

Direct json link (the result is equal to filtering all earth_event with category)

description

Description of category

layers

Layers of category (see oficial documentation)

Examples

## Not run: 
categories <- eonet_categories()

## End(Not run)

Calls EONET sources webservice

Description

Calls NASA's EONET Webservice and returns all sources available.

Usage

eonet_sources()

Value

Returns data.frame with 4 columns:

id

Unique id (can be used to filter earth_event)

title

Title of source

source

Official source URL

link

Direct json link (the result is equal to filtering all earth_event with source)

Examples

## Not run: 
sources <- eonet_sources()

## End(Not run)

Plots the image to device

Description

To avoid S4 Classes and methods, this small wrapper simply plots an image from NASA. If the purpose is to this interactively on one image, set the parameter plot = TRUE in earth_image.

Usage

plot_earth_image(image_raster_data)

Arguments

image_raster_data

image downloaded using earth_image.

Value

nothing

See Also

earth_image

Examples

## Not run: 
key <- "123key"
img <- earth_image(key, -100.31008, 25.66779, "2016-01-01")
plot_earth_image(img$image_png)

## End(Not run)