1

I want to find out an unknown target location (latitude and longitude co-ordinates). There are +3 lat-long known points and for each point a distance in meters to the target location. I found some code on internet like this, this and this but when I put my coordinates it gives this error which I couldn't solve.

z = numpy.sqrt(pow(DistA,2) - pow(x,2) - pow(y,2))

RuntimeWarning: invalid value encountered in sqrt

the coordinates are (lat, lon, radius(m))

40.222167, 28.871361, 50
40.22175,  28.87169, 50
40.222528, 28.872083, 50

enter image description here

Could the error be due to location difference?

5
  • The square root of a negative number is imaginary.
    – Vince
    Mar 31, 2022 at 3:17
  • @Vince Yes you're right but how can I solve this problem, why the result is negative? the coordinates that used in the codes I mentioned don't give negative result.
    – ajanx
    Apr 2, 2022 at 11:46
  • You haven't provided the values of your variables, but the only way to generate that error is a negative value.
    – Vince
    Apr 2, 2022 at 13:10
  • @Vince the values are the coordinates and radius I wrote above
    – ajanx
    Apr 4, 2022 at 2:10
  • Your code has DistA, x, and y, and your data has lat, lon, and radius. Try printing the contents of the variables before executing the square root.
    – Vince
    Apr 4, 2022 at 4:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.