Search code examples
pythongoogle-mapsgeometrymap-projectionsradians

Python - get the ratios between degrees and meters, depending on coordinates on a (google) map


I am trying to find spots that block a circle (a,b,R) on a map, the problem is that coordinates used on the map are translated to different metric values as longitude changes. i know it has something to do with radians. this is the code with the missing part:

class Circle(object):
    def __init__(self,x,y,R):   
        self.x = x #Degrees
        self.y = y #Degrees
        self.R = R #meters

    def getRatio(self,x,y):     
        #This is where the magic happens...
        return latRatio, LatRatio


    def getBlockingSquareCords(self):
        latRation, lonRatio = getLonRatio(x,y)
        latD = self.R/latRatio
        lonD = self.R/lonRatio

        x1 = self.x+latD
        y1 = self.y+lonD

        x2 = self.x-latD
        y2 = self.y-lonD

        return (x1,y1,x2,y2)

this following question has some hints to the answer, but i couldn't figure it out -Calculate distance between two latitude-longitude points? (Haversine formula)


Solution

  • It does depend only on latitude (because the circles are getting smaller when you move towards poles).

    Latitude:  1 deg = 110.54 km
    Longitude: 1 deg = 111.320*cos(latitude) km