satellite.py
In this script we will plot the position of ISS. In order to do this we will use this API.
Import the required modules pandas and plotly
import pandas as pd
import plotly.express as px
We will use the API found here.
url = ‘http://api.open-notify.org/iss-now.json'
Next we need to read our data which are in a json format (some kind of file)
dataFrame = pd.read_json(url)
Print the dataFrame and see our results
print(dataFrame)
Let’s shape a little bit our data the way we want them to be.
dataFrame[‘latitude’] = dataFrame.loc[‘latitude’,’iss_position’]
dataFrame[‘longitude’] = dataFrame.loc[‘longitude’, ‘iss_position’]
dataFrame.reset_index(inplace=True)
print the data again…do you see the diferrence?
Now let’s get rid of some data and fine tune them
dataFrame = dataFrame.drop([‘index’, ‘message’], axis=1)
Let’s plot out data
figure = px.scatter_geo(dataFrame, lat=”latitude”, lon=”longitude”)
figure.show()