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?

ajanx
  • 11
  • 2
  • The square root of a negative number is imaginary. – Vince Mar 31 '22 at 03: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 02 '22 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 02 '22 at 13:10
  • @Vince the values are the coordinates and radius I wrote above – ajanx Apr 04 '22 at 02: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 04 '22 at 04:25

0 Answers0