Coder Social home page Coder Social logo

Comments (7)

jdeniau avatar jdeniau commented on August 14, 2024 1

Hi,

For a little context, I do not work with python on a daily basis.

shapely seems to be a knowned library to handle, according to the README:

manipulation and analysis of planar geometric objects

With haversine, you try to manipulate latitude and longitude. As we might link x / y to lat / lng, I fear that it will lead to imprecision and possible bugs for users that not understand that x/y on a plan are not really the same as lat / lng.

It's not a hard no, but I would prefer understand your use case to implement this.

A possible workaround for you is to create an adapter in your code:

def point_to_tuple(p: Point) -> (number, number):
    return (p.x, p.y)

from haversine.

jdeniau avatar jdeniau commented on August 14, 2024

Hi, can you provide an example of what you want exactly ?

Thanks

from haversine.

yesthisischris avatar yesthisischris commented on August 14, 2024

from haversine.

hcm444 avatar hcm444 commented on August 14, 2024

I was interested in this because I use the haversine library and shapely

no need to modify the library, just extract the point co-ordinates from the objects and calculate the haversine distance.

from haversine import haversine
from shapely.geometry import Point
lyon = (45.7597, 4.8422) # (lat, lon)
paris = (48.8567, 2.3508)
lyon_point = Point(lyon[1], lyon[0]) 
paris_point = Point(paris[1], paris[0])
lyon_coords = (lyon_point.y, lyon_point.x)
paris_coords = (paris_point.y, paris_point.x)
print(haversine(lyon_coords, paris_coords))

This returns 392.2172595594006

from haversine.

jdeniau avatar jdeniau commented on August 14, 2024

@hcm444 Doesn't the proposed adapter suits your need ?

from haversine.

hcm444 avatar hcm444 commented on August 14, 2024

@hcm444 Doesn't the proposed adapter suits your need ?

Yes sir, I guess we can close this issue, correct?

from haversine.

jdeniau avatar jdeniau commented on August 14, 2024

Yes, I'm closing this 👍

from haversine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.