Question

Using python3 pls Problem 1: Write a Python function that uses spherical polar coordinates to det...

using python3 pls

Problem 1: Write a Python function that uses spherical polar coordinates to determine the distance between any two points on the earth's surface. The function will take as input two points, given in spherical polar coordinates, i.e. longitude and latitude. Assume your points are on the earth's surface, and that the earth is a sphere of radius 6378km

0 0
Add a comment Improve this question Transcribed image text
Answer #1


"""
  Python 3
  Program to find distance between two earth coordinates
"""

from math import radians, sin, cos, acos

print("Input coordinates of two points:")
startLat = radians(float(input("Starting latitude: ")))
startLon = radians(float(input("Starting longitude: ")))
endLat = radians(float(input("Ending latitude: ")))
endLon = radians(float(input("Ending longitude: ")))

dist = 6378 * acos(sin(startLat)*sin(endLat) + cos(startLat)*cos(endLat)*cos(startLon - endLon))
print("The distance is %.2fkm." % dist)

# Code ends here
Add a comment
Know the answer?
Add Answer to:
Using python3 pls Problem 1: Write a Python function that uses spherical polar coordinates to det...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C programming, code the following function: Write the function Location() that takes in two pairs...

    In C programming, code the following function: Write the function Location() that takes in two pairs of DEGREE (latitude, longitude) coordinates and returns the great-circle-distance between the points on the surface of the Earth, which is calculated using the formula: d = R acos[ cos(latA)cos(latB)cos(lonB-lonA) + sin(latA)sin(latB) ] where (latA,lonA) and (latB,lonB) are the RADIAN coordinates for the two points, R = 6368 km is the radius of the Earth (provided in the template as a global variable), d is...

  • BOX 5.1 The Polar Coordinate Basis Consider ordinary polar coordinates r and 0 (see figure 5.3)....

    BOX 5.1 The Polar Coordinate Basis Consider ordinary polar coordinates r and 0 (see figure 5.3). Note that the distance between two points with the same r coordinate but separated by an infinitesimal step do in 0 is r do (by the definition of angle). So there are (at least) two ways to define a basis vector for the direction (which we define to be tangent to the r = constant curve): (1) we could define a basis vector es...

  • Write the vector differential operator "DEL-V in Cartesian coordinates Cylindrical coordinates Spherical coordinates. 2. Show for...

    Write the vector differential operator "DEL-V in Cartesian coordinates Cylindrical coordinates Spherical coordinates. 2. Show for any "nice" scalar function (x,y,z), the Curl of the gradient of (x,y,z) is Zero.. VxVo = 0 Hint: assume the order of differentiation can be switched 3. Find the volume of a sphere of radius R by integrating the infinitesimal volume element of the sphere. 4. Write Maxwell's equations for the case of electro and magneto statics (the fields do not change in time)...

  • Please answer all questions for UPVOTE LOCATION: Cleveland, Ohio DREAM LOCATION: Rome, Italy PRECALCULUS: VECTORS Directions: Suppose that you plan to take a trip to your dream destina...

    Please answer all questions for UPVOTE LOCATION: Cleveland, Ohio DREAM LOCATION: Rome, Italy PRECALCULUS: VECTORS Directions: Suppose that you plan to take a trip to your dream destination. You would like to know the shortest distance between your starting point and your destination. When calculating distances on a plane, you need only consider two dimensions because you are on a flat surface. However, when finding distances between two points on Earth, you must take into the account the curvature of...

  • Pls write python code 1. We want to obtain the volume contained between a sphere of radius 0.75 a...

    Pls write python code 1. We want to obtain the volume contained between a sphere of radius 0.75 and another larger sphere of radius1. Modify the Monte Carlo written for the volume of a sphere. Use N=10,000 sampling points (random points in the cube) ax

  • 5. (a) 4points Figure 2 below shows the annual average radiation budget as a function of latitude...

    5. (a) 4points Figure 2 below shows the annual average radiation budget as a function of latitude. Estimate the latitude Lc where the net radiation crosses over from positive to negative in the Northern Hemisphere. Also estimate the value of the net radiation at the North Pole. Use the two pieces of information to find the equation of a straight line that approximately describes the net radiation (in WIm2) as a function of latitude L between 10 N and the...

  • Suppose that p- and s-waves traveled in straight lines through the Earth (in fact, they don't,...

    Suppose that p- and s-waves traveled in straight lines through the Earth (in fact, they don't, but we will make this approximation for this problem). Also suppose that the angular distance from the epicenter (location of the earthquake) on the Earth's spherical surface to the location on the surface beyond which no s-waves can be observed from an earthquake (the angle between the earthquake epicenter and the s shadow zone) is 120 degrees (i.e., the two points are located 1/3...

  • Only need help with (d) = 0 ( [this point is away from 0] A conducting...

    Only need help with (d) = 0 ( [this point is away from 0] A conducting sphere of radius a is hollow and grounded (V = 0). A particle of charge q is a placed inside at a distance b from the center. We wish to find the potential anywhere inside the sphere. This problem can be solved with the image charge method. The image charge d' should be placed a distance b = from the center, so that the...

  • 1(a)    Write a python program using a function name slope(x1, y1, x2, y2) that returns...

    1(a)    Write a python program using a function name slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). 1(b) For problem 1(a), write a python program using a function name Euclidean_dist(x1, y1, x2, y2) which will calculate and return the Euclidean distance between the points (x1, y1) and (x2, y2).

  • Python Program 5. Write a Python program in a file named validTime.py. Include a function named...

    Python Program 5. Write a Python program in a file named validTime.py. Include a function named string parameter of the form hh:mm: ss in which these are numeric validTime that takes a values and returns True or False indicating whether or not the time is valid. The number of hours, minutes, and seconds must two digits and use a between 0 and 9). The number of hours must be between 0 and 23, the number of minutes and seconds must...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT