For a section of a project I'm working on at University, I'm trying to recreate the Earth using Python and use that to plot specific locations on the surface and plot circles in various orientations, so they align with satellite data I have to give a representation of an airplane's location at a given time from the data set.
I started off by simply plotting a wireframe and plotted the points on the wireframe that I needed (all to scale the Earth and its geographical locale).
The issue I'm having is when I plot the points on a sphere-ish object with an image of the Earth overlayed on top, the points disappear when rotating the sphere past a certain point. So, the initial question is: How can I stop them from disappearing?
Second of all; I can't seem to find any way to plot circles centered on the sphere - for example, a circle around the equator and then manipulate that same idea to plot circles on the surface of the sphere to give an image like below:
I know this is from google maps, but I'm curious if this can be done in Python (I assume so).
My current code is:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from itertools import product, combinations
import PIL
#Plot the Earth
f = plt.figure(1, figsize=(13,13))
ax = f.add_subplot(111, projection='3d')
u, v = np.mgrid[0:2*np.pi:30j, 0:np.pi:20j]
x=6371*np.cos(u)*np.sin(v)
y=6371*np.sin(u)*np.sin(v)
z=6371*np.cos(v)
ax.plot_wireframe(x, y, z, color="b")
#GES ground station @ Perth & AES @ KLIA
ax.scatter([-2368.8],[4881.1],[-3342.0],color="r",s=100)
ax.scatter([-1293.0],[6238.3],[303.5],color="k",s=100)
#Load earthmap with PIL
bm = PIL.Image.open('earthmap.jpg')
#It's big, so I'll rescale it, convert to array, and divide by 256 to get RGB values that matplotlib accept
bm = np.array(bm.resize([d/3 for d in bm.size]))/256.
#d/1 is normal size, anything else is smaller - faster loading time on Uni HPC
#Coordinates of the image - don't know if this is entirely accurate, but probably close
lons = np.linspace(-180, 180, bm.shape[1]) * np.pi/180
lats = np.linspace(-90, 90, bm.shape[0])[::-1] * np.pi/180
#Repeat code specifying face colours
x = np.outer(6371*np.cos(lons), np.cos(lats)).T
y = np.outer(6371*np.sin(lons), np.cos(lats)).T
z = np.outer(6371*np.ones(np.size(lons)), np.sin(lats)).T
ax.plot_surface(x, y, z, rstride=4, cstride=4, facecolors = bm)
plt.show()
If there is any way I can get it so the points stop disappearing and plot even just a circle on the equator, that'd be great!
Thanks!