Team Updates

from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

import numpy as np

from tkinter import *

root = Tk()

root.geometry("900x600")

root.title("Classes")

dictionary = {}

dictionary["Lat"] = 0

dictionary["Lon"] = 0

dictionary["Location"] = "Missisauga, ON"

lat_temp = IntVar()

lon_temp = IntVar()

location_temp = StringVar()

 

 

 

def finish():

    global lat_input

    global lon_input

    global location_input

    dictionary["Lat"] = lat_temp.get()

    print(dictionary["Lat"])

    dictionary["Lon"] = lon_temp.get()

    print(dictionary["Lon"])

    dictionary["Location"] = location_temp.get()

    print(dictionary["Location"])

 

    dictionary["Lat"] = lat_temp.get()

    dictionary["Lon"] = lon_temp.get()

    dictionary["Location"] = location_temp.get()

   

 

   

text = Label(root, text="Enter Your Latitude")

text.place(x=70,y=105)



from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

import numpy as np

from PIL import Image

import json

import urllib.request

 

issimage = Image.open("iss.gif")

fig = plt.figure(figsize=(7,6))

 

while(True):

 

   url = 'http://api.open-notify.org/iss-now.json'

   response = urllib.request.urlopen(url)

   result = json.loads(response.read())

 

   location = result['iss_position']

   lat = float(location['latitude'])

   lon = float(location['longitude'])

   print('Latitude: ', lat)

   print('Longitude: ', lon)

 

   # set perspective angle

   lat_viewing_angle = -25.274

   lon_viewing_angle = 133.77

 

   # define color maps for water and land

   ocean_map = (plt.get_cmap('ocean'))(210)

   cmap = plt.get_cmap('gist_earth')

 

   # call the basemap and use orthographic projection at viewing angle

   m1 = Basemap(projection='ortho',

           lat_0=lat_viewing_angle,lon_0=lon_viewing_angle,resolution=None)

 

   # define map coordinates from full-scale globe

   map_coords_xy = [m1.llcrnrx,m1.llcrnry,m1.urcrnrx,m1.urcrnry]

   map_coords_geo = [m1.llcrnrlat,m1.llcrnrlon,m1.urcrnrlat,m1.urcrnrlon]

 

   #zoom proportion and re-plot map

   zoom_prop = 1.0 # use 1.0 for full-scale map

 

   m = Basemap(projection='ortho',resolution='l',

           lat_0=lat_viewing_angle,lon_0=lon_viewing_angle,llcrnrx=-map_coords_xy[2]/zoom_prop,

               llcrnry=-map_coords_xy[3]/zoom_prop,urcrnrx=map_coords_xy[2]/zoom_prop,

               urcrnry=map_coords_xy[3]/zoom_prop)

 

   # coastlines, map boundary, fill continents/water, fill ocean, draw countries

   m.drawmapboundary(fill_color=ocean_map)

   m.fillcontinents(color=cmap(200),lake_color=ocean_map)

   m.drawcoastlines()

   m.drawcountries()

 

   # latitude/longitude line vectors

   lat_line_range = [-90,90]

   lat_lines = 8

   lat_line_count = (lat_line_range[1]-lat_line_range[0])/lat_lines

 

   merid_range = [-180,180]

   merid_lines = 8

   merid_count = (merid_range[1]-merid_range[0])/merid_lines

 

   m.drawparallels(np.arange(lat_line_range[0],lat_line_range[1],lat_line_count))

   m.drawmeridians(np.arange(merid_range[0],merid_range[1],merid_count))

 

   # scatter to indicate lat/lon point

   x,y = m(lon_viewing_angle,lat_viewing_angle)

   m.scatter(x,y,marker='o',color='#DDDDDD',s=3000,zorder=10,alpha=0.7,\

           edgecolor='#000000')

   m.scatter(x,y,marker='o',color='#000000',s=100,zorder=10,alpha=0.7,\

           edgecolor='#000000')

 

   plt.annotate('Insert name', xy=(x, y),  xycoords='data',

                   xytext=(-110, -10), textcoords='offset points',

                   color='k',fontsize=12,bbox=dict(facecolor='w', alpha=0.5),

                   arrowprops=dict(arrowstyle="fancy", color='k'),

                   zorder=20)

 

   # save figure at 150 dpi and show it

   plt.savefig('ortho_zoom_example.png',dpi=150,transparent=True)

   plt.show()

   plt.imshow(issimage, alpha=0.5)

 

print("It's not working")




____________


WORKING CODE:

from mpl_toolkits.basemap import Basemap

import matplotlib.pyplot as plt

import numpy as np

from tkinter import *

from PIL import Image

import json

import urllib.request

 

issimage = Image.open("iss.gif")

fig = plt.figure(figsize=(7,6))

while(True):

    url = 'http://api.open-notify.org/iss-now.json'

    response = urllib.request.urlopen(url)

    result = json.loads(response.read())

 

    location = result['iss_position']

    lat_iss = float(location['latitude'])

    lon_iss = float(location['longitude'])

    print('Latitude: ', lat_iss)

    print('Longitude: ', lon_iss)

    ocean_map = (plt.get_cmap('ocean'))(210)

    cmap = plt.get_cmap('gist_earth')

 

    # call the basemap and use orthographic projection at viewing angle

    m1 = Basemap(projection='ortho',

            lat_0=lat_iss,lon_0=lon_iss,resolution=None)

 

    # define map coordinates from full-scale globe

    map_coords_xy = [m1.llcrnrx,m1.llcrnry,m1.urcrnrx,m1.urcrnry]

    map_coords_geo = [m1.llcrnrlat,m1.llcrnrlon,m1.urcrnrlat,m1.urcrnrlon]

 

    #zoom proportion and re-plot map

    zoom_prop = 2.0 # use 1.0 for full-scale map

 

    m = Basemap(projection='ortho',resolution='l',

            lat_0=lat_iss,lon_0=lon_iss,llcrnrx=-map_coords_xy[2]/zoom_prop,

            llcrnry=-map_coords_xy[3]/zoom_prop,urcrnrx=map_coords_xy[2]/zoom_prop,

            urcrnry=map_coords_xy[3]/zoom_prop)

 

    # coastlines, map boundary, fill continents/water, fill ocean, draw countries

    m.drawmapboundary(fill_color=ocean_map)

    m.fillcontinents(color=cmap(200),lake_color=ocean_map)

    m.drawcoastlines()

    m.drawcountries()

 

    # latitude/longitude line vectors

    lat_line_range = [-90,90]

    lat_lines = 8

    lat_line_count = (lat_line_range[1]-lat_line_range[0])/lat_lines

 

    merid_range = [-180,180]

    merid_lines = 8

    merid_count = (merid_range[1]-merid_range[0])/merid_lines

 

    m.drawparallels(np.arange(lat_line_range[0],lat_line_range[1],lat_line_count))

    m.drawmeridians(np.arange(merid_range[0],merid_range[1],merid_count))

 

    # scatter to indicate lat/lon point

    x,y = m(lon_iss,lat_iss)

    m.scatter(x,y,marker='o',color='#DDDDDD',s=3000,zorder=10,alpha=0.7,\

            edgecolor='#000000')

    m.scatter(x,y,marker='o',color='#000000',s=100,zorder=10,alpha=0.7,\

            edgecolor='#000000')

 

    plt.annotate(str("ISS Location"), xy=(x, y),  xycoords='data',

                xytext=(-110, -10), textcoords='offset points',

                color='k',fontsize=12,bbox=dict(facecolor='w', alpha=0.5),

                arrowprops=dict(arrowstyle="fancy", color='k'),

                zorder=20)

 

    # save figure at 150 dpi and show it

    plt.savefig('ortho_zoom_example.png',dpi=150,transparent=True)

    plt.show()




yusufrYusuf Hussain