distance

Latitude / Longitude and meters

醉酒当歌 提交于 2019-12-05 21:49:49
问题 I have a small algorithmic problem. I am developing an Android application. I get GPS coordinates. For example: latitude: 23.23907 , longitude: 50.45786 . So I get a point. I want to compute bounds details on this point plus or minus 5 meters. I.e.: [23.23907 - 5 meters ; 23.23907 + 5 meters] [50.45786 - 5 meters ; 50.45786 + 5 meters] How to make this calculation? Thank you very much! 回答1: The haversine formula can be simplified a great deal when you work in north-south and east-west

R - Calculate distance between two points along a polyline

狂风中的少年 提交于 2019-12-05 21:27:02
In R - I have imported a polyline shapefile that is not straight (represents a winding interstate highway) into the environment. I have read a .csv file that contains points (latitude/longitude in decimal degrees) into the environment. All of those points lie along the polyline. If I take two random points I can calculate the "as the crow flies" distance between them using great circle distance calculation. But what is needed is distance traveled along the polyline. See reference image: https://i.stack.imgur.com/zhorb.png Is anyone aware of an R package that can calculate the distance between

How to speed up nearest search in Pandas (perhaps by vectorizing code)

只愿长相守 提交于 2019-12-05 21:04:35
I have two dataframes. Each one contains locations (X,Y) and a value for that point. For each point in the first dataframe I want to find the closest point in the second dataframe and then find the difference. I have code that is working, but it uses a for loop, which is slow. Any suggestions for how to speed this up? I know that it is generally a good idea to get rid of for loops in pandas, for performance, but I don't see how to do that in this case. Here is some sample code: import pandas as pd import numpy as np df1=pd.DataFrame(np.random.rand(10,3), columns=['val', 'X', 'Y']) df2=pd

Efficiently delete arrays that are close from each other given a threshold in python

时间秒杀一切 提交于 2019-12-05 17:56:16
I am using python for this job and being very objective here, I want to find a 'pythonic' way to remove from an array of arrays the "duplicates" that are close each other from a threshold. For example, give this array: [[ 5.024, 1.559, 0.281], [ 6.198, 4.827, 1.653], [ 6.199, 4.828, 1.653]] observe that [ 6.198, 4.827, 1.653] and [ 6.199, 4.828, 1.653] are really close to each other, their Euclidian distance is 0.0014 , so they are almost "duplicates", I want my final output to be just: [[ 5.024, 1.559, 0.281], [ 6.198, 4.827, 1.653]] The algorithm that I have right now is: to_delete = []; for

Measuring distance with iPhone camera

蹲街弑〆低调 提交于 2019-12-05 16:09:24
问题 How to implement a way to measure distances in real time (video camera?) on the iPhone, like this app that uses a card to compare the size of the card with the actual distance? Are there any other ways to measure distances? Or how to go about doing this using the card method? What framework should I use? 回答1: Well you do have something for reference, hence the use of the card. Saying that after watching the a video for the app I can't seem it seems too user friendly. So you either need a

Android: best method to calculate distance between two locations

六月ゝ 毕业季﹏ 提交于 2019-12-05 12:17:10
i researched a little in this topic, but there are many opinions that don't exactly give a clear image. My problem is this: I'm developing a gps-based app for Android, in wich i want to know distance between my current location specified by Androids LocationManager, and other location in real time. I tried Haversine formula, a Law of Cosines formula, then I discovered, that Android SDK gives me a simple function Location.distanceTo(Location) - i'm not sure what method does this function runs on. So, the point is, wich one will be good for me to use, in situations when real distance between

How to calculate Euclidean length of a matrix without loops?

假如想象 提交于 2019-12-05 07:58:33
It seems like the answer to this should be simple, but I am stumped. I have a matrix of Nx3 matrix where there 1st 2nd and 3rd columns are the X Y and Z coordinates of the nth item. I want to calculate the distance from the origin to the item. In a non vectorized form this is easy. distance = norm([x y z]); or distance = sqrt(x^2+y^2+z^2); However, in vectorized form its not so simple. When you pass a matrix to norm it no longer returns the Euclidean length. distance = norm(matrix); %doesn't work and distance = sqrt(x(:,1).*x(:,1)+y(:,2).*y(:,2)+z(:,3).*z(:,3)); %just seems messy Is there a

Recalculating distance matrix

狂风中的少年 提交于 2019-12-05 07:54:57
问题 I’ve got a large input matrix (4000x10000). I use dist() to calculate the Euclidean distance matrix for it (it takes about 5 hours). I need to calculate the distance matrix for the "same" matrix with an additional row (for a 4001x10000 matrix). What is the fastest way to determine the distance matrix without recalculating the whole matrix? 回答1: I'll assume your extra row means an extra point. If it means an extra variable/dimension, it will call for a different answer. First of all, for

Google Map API v2 - Get Driving Distance from Current Location to Known Locations

帅比萌擦擦* 提交于 2019-12-05 07:41:43
问题 I'm trying to figure out how to display the driving distance from the current location to four known locations. I'm not showing a map on the screen, I just need to display how many miles away the user currently is from those locations. I took an example from Here and modified it a little. It is bringing back the correct distance but I can't figure out how to pass in each of the 4 end locations, or differentiate between them. What do I need to do in order to get the distance to each of the 4

FInd latitude longitude point in php given initial lat lng, distance, and bearing

泄露秘密 提交于 2019-12-05 07:04:02
In php, given a latitude and longitude point, a bearing (in degrees), and a distance (in feet or km or whatever) how do I figure out what the new lat lng point is? here is what I tried, but it's wrong. function destinationPoint($lat, $lng, $brng, $dist) { $meters = $dist/3.2808399; // dist in meters $dist = $meters/1000; // dist in km $rad = 6371; // earths mean radius $dist = $dist/$rad; // convert dist to angular distance in radians $brng = deg2rad($brng); // conver to radians $lat1 = deg2rad($lat); $lon1 = deg2rad($lng); $lat2 = asin(sin($lat1)*cos($dist) + cos($lat1)*sin($dist)*cos($brng)