distance

geodesic distance transform in python

允我心安 提交于 2020-01-11 23:08:06
问题 In python there is the distance_transform_edt function in the scipy.ndimage.morphology module. I applied it to a simple case, to compute the distance from a single cell in a masked numpy array. However the function remove the mask of the array and compute, as expected, the Euclidean distance for each cell, with non null value, from the reference cell, with the null value. Below is an example I gave in my blog post: %pylab from scipy.ndimage.morphology import distance_transform_edt l = 100 x,

geodesic distance transform in python

筅森魡賤 提交于 2020-01-11 23:08:02
问题 In python there is the distance_transform_edt function in the scipy.ndimage.morphology module. I applied it to a simple case, to compute the distance from a single cell in a masked numpy array. However the function remove the mask of the array and compute, as expected, the Euclidean distance for each cell, with non null value, from the reference cell, with the null value. Below is an example I gave in my blog post: %pylab from scipy.ndimage.morphology import distance_transform_edt l = 100 x,

Check if point is inside a circle

旧时模样 提交于 2020-01-11 10:46:09
问题 I have a point expressed in lat/long Position louvreMuseum = new Position( 48.861622, 2.337474 ); and I have a radius value expressed in meters. I need to check if another point, also expressed in lat/long, is inside the circle. If I were on a flat surface I can simply use the formula (x - center_x)^2 + (y - center_y)^2 <= radius^2 as deeply explained in these SO answer. However as per the latitude/longitude usage I can not use that formula because of the spherical nature of the planet. How

Check if point is inside a circle

我只是一个虾纸丫 提交于 2020-01-11 10:46:09
问题 I have a point expressed in lat/long Position louvreMuseum = new Position( 48.861622, 2.337474 ); and I have a radius value expressed in meters. I need to check if another point, also expressed in lat/long, is inside the circle. If I were on a flat surface I can simply use the formula (x - center_x)^2 + (y - center_y)^2 <= radius^2 as deeply explained in these SO answer. However as per the latitude/longitude usage I can not use that formula because of the spherical nature of the planet. How

Given point of (latitude,longitude), distance and bearing, How to get the new latitude and longitude

情到浓时终转凉″ 提交于 2020-01-11 09:33:10
问题 I found a piece of code on web. It calculates the Minimum bounding rectangle by a given lat/lon point and a distance. private static void GetlatLon(double LAT, double LON, double distance, double angle, out double newLon, out double newLat) { double dx = distance * 1000 * Math.Sin(angle * Math.PI / 180.0); double dy = distance * 1000 * Math.Cos(angle * Math.PI / 180.0); double ec = 6356725 + 21412 * (90.0 - LAT) / 90.0; double ed = ec * Math.Cos(LAT * Math.PI / 180); newLon = (dx / ed + LON *

Distance Between Two Points in Matlab

冷暖自知 提交于 2020-01-11 09:22:07
问题 I have 2 vectors one is 200*2 in dimension and other is 3*2.All of them are points in a cartesian coordinate system. I want to calculate the distance between the first 200 and the other 3 points and store them in a vector. I'm using a function like this; for i=1:cur for j=1:200 L(j,i)=sqrt(square(P2(i,1)-C(j,1))+square(P2(i,2)-C(j,2))) end end where cur is 3 , P2 being the 3*2 vector and C being the 200*2.Now the results i get are completely wrong but I cannot figure out the problem in that.

Python 3.5.2 : Distance from a point to a line

左心房为你撑大大i 提交于 2020-01-11 04:14:07
问题 I have created a class "Point" and i want to calculate the shortest distance between a given point and a line ( characterized by 2 other points ), all points are known. I tried to use this formula : |Ax+By+C| / sqrt(A^2+B^2) , but i messed up and got more confused by the minute (mostly because of math formulas :( )... I did find some sites where people asked this question too, but it either was not for Python or it was in a 3D system not 2D ... ​​ Below is my class : class Point: def __init__

SQL Distance Query without Trigonometry

廉价感情. 提交于 2020-01-10 20:15:11
问题 I have an SQLite database, which does not support trig functions. I would like to sort a set of lat,lng pairs in my table by distance as compared to a second lat,lng pair. I'm familiar with the standard haversine distance formula for sorting lat,lng pairs by distance. In this case I don't care particularly for precision, my points are separated by large distances, so I don't mind rounding off the distances by treating curves as straight lines. My question, is there a generally accepted

Pandas: calculate haversine distance within each group of rows

不想你离开。 提交于 2020-01-10 04:25:31
问题 The sample CSV is like this: user_id lat lon 1 19.111841 72.910729 1 19.111342 72.908387 2 19.111542 72.907387 2 19.137815 72.914085 2 19.119677 72.905081 2 19.129677 72.905081 3 19.319677 72.905081 3 19.120217 72.907121 4 19.420217 72.807121 4 19.520217 73.307121 5 19.319677 72.905081 5 19.419677 72.805081 5 19.629677 72.705081 5 19.111860 72.911347 5 19.111860 72.931346 5 19.219677 72.605081 6 19.319677 72.805082 6 19.419677 72.905086 I know I can use haversine for distance calculation (and

Working out the distance between two postcodes

拟墨画扇 提交于 2020-01-07 09:07:11
问题 I have looked at other questions that have been answered however, I am still unsure on how to; Get UK postcode data including Longitude, Latitude, Grid-N and Grid-E into my database If I use an API how do I go about it? Where do I start from? Would I need to use Pythagorus Theorem to calculate the distance between the two postcodes? I have got a table in my database for when a user adds a property. Maybe, there is a way when someone adds a property, it can add that postcode along with the