NASA Assignment 6

Introduction

This is using information from the NASA API to track where the International Space Station is in orbit. Whether a fan of space or someone working with NASA to keep track of where our Astronauts are in relative comparison to Earth, this tool can serve the needs of multiple different types of users.

Load Libraries

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.1     ✔ tibble    3.3.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.2
✔ purrr     1.2.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(jsonlite)

Attaching package: 'jsonlite'

The following object is masked from 'package:purrr':

    flatten
library(magrittr)

Attaching package: 'magrittr'

The following object is masked from 'package:purrr':

    set_names

The following object is masked from 'package:tidyr':

    extract
library(httr)

Load your URLs

nasa_base_url <-"http://api.open-notify.org/"
iss_current_location <- paste0(nasa_base_url,"iss-now.json")

Tie it together

iss_data <- iss_current_location %>% 
  GET() %>% 
  content(as = "text",
          encoding = "UTF-8") %>% 
  fromJSON() %>% 
  use_series(iss_position)

Define Longitude & Latitude from the Data

longitude <- as.numeric(iss_data$longitude)
latitude <- as.numeric(iss_data$latitude)

Output the current location

cat("Current ISS Location:",
    "Latitude:", latitude,
    "Longitude:", longitude)
Current ISS Location: Latitude: 28.6401 Longitude: 47.0355

Findings

Using this code, anyone can quickly and easily locate where our International Space Station is located based off of when the code is ran. For those who are deeply interested in following how our ISS path moves, this tool would be extremely useful.