distance

Figuring out distance and course between two coordinates

倖福魔咒の 提交于 2019-12-06 08:33:23
问题 I have 2 coordinates and would like to do something seemingly straightforward. I want to figure out, given: 1) Coordinate A 2) Course provided by Core Location 3) Coordinate B the following: 1) Distance between A and B (can currently be done using distanceFromLocation) so ok on that one. 2) The course that should be taken to get from A to B (different from course currently traveling) Is there a simple way to accomplish this, any third party or built in API? Apple doesn't seem to provide this

How to use distHaversine function?

夙愿已清 提交于 2019-12-06 08:27:47
I am trying to use the distHavrsine function in R, inside a loop to calculate the distance between some latitude and longitude coordinates for a several hundred rows. In my loop I have this code: if ((distHaversine(c(file[i,"long"], file[i,"lat"]), c(file[j,"long"], file[j,"lat"]))) < 50 ) after which if the distance is less than 50 meters i want it to record those rows, and where the latitude and longitude coordinates it is referencing look like: 0.492399367 30.42530045 and 0.496899361 30.42497045 but i get this error Error in .pointsToMatrix(p1) : latitude > 90 i get this error "Error in

Distance from Point To Line great circle function not working right.

爷,独闯天下 提交于 2019-12-06 06:20:08
问题 I need to get the distance from a lat/lng point to a line. Of course needs to follow the Great Circle. I found a great article on this at http://www.movable-type.co.uk/scripts/latlong.html but the code is not working right. Either I am doing something wrong or there is something missing. Here is the function in question. See the link for the other functions if needed. var R = 3961.3 LatLon.crossTrack = function(lat1, lon1, lat2, lon2, lat3, lon3) { var d13 = LatLon.distHaversine(lat1, lon1,

Location and distance calculation using Wifi in android

核能气质少年 提交于 2019-12-06 05:52:49
问题 How to get the distance of our mobile device from a wifi hotspot kept inside a building? This is basically for navigational purposes inside the building.. Any help would be appreciated. 回答1: If you want to use WiFi for indoor location (step 1 before navigation), then distance to the WiFi Access Points is not the correct approach. Instead use RSSI. With Android you would need to take WiFi fingerprint of a building by moving around every few meters and sample the RSSI strength. You need to

Calculating distance of an AP including signal-to-noise ratio

不羁的心 提交于 2019-12-06 05:04:04
For some reason a friend and myself were talking about calculating the distance between yourself (laptop, phone, etc.) and an AP based of the info you get from the devices (RSSI, freq, SNR, etc...). So, after spending sometime researching about trilateration, triangulation, and free-space path loss. (with the help of some blog posts and wiki) I was able to get a distance in meters from the AP to my laptop and the results were a lot better then what I thought they would be. Whenever I'm in the same room or there's a line of sight to the AP, the accuracy is about a foot. But now, I want to take

Mahalanobis distance of each pair of observations

馋奶兔 提交于 2019-12-06 04:31:58
I am trying to compute the Mahalanobis distance between each observations of a dataset dat , where each row is an observation and each column is a variable. Such distance is defined as: I wrote a function that does it, but I feel like it is slow. Is there any better way to compute this in R ? To generate some data to test the function: generateData <- function(nObs, nVar){ library(MASS) mvrnorm(n=nObs, rep(0,nVar), diag(nVar)) } This is the function I have written so far. They both work and for my data (800 obs and 90 variables), it takes approximatively 30 and 33 seconds for the method =

Calculate the distance between two points in iphone

自作多情 提交于 2019-12-06 03:18:28
I am creating an application that requires the user to input two places (Postal codes). My application will calculate the driving-distance between these two points ad output the result. The user has the option of adding Way-Points. I think I would have to use the google maps API and get an xml file with the result and then parse the xml file. Can anyone help me because i not sure how to do this. Appreciate all help. Example... Start: BR1 1LR Waypoint: BR2 0LH Waypoint: BR3 4AY Destination: BR1 1LR Yes you can calculate the distance ,for that you need to have the latitude and longitude to get

Use pdist() in python with a custom distance function defined by you

旧城冷巷雨未停 提交于 2019-12-06 03:05:56
问题 I have been interested in usage of scipy.spatial.distance.pdist(...) in python which has come to be useful and fast for some of the applications I have been working on. I need to use a pairwise distance function which are custom and not standard default distance metrics as defined by the metric. Let's make a simple example, suppose I do not want to use euclidean distance function as the following: Y = pdist(X, 'euclidean') Instead I want to define the euclidean function myself and pass it as

Shortest distance between point and path

我们两清 提交于 2019-12-06 02:36:45
for a geo-based online game I'm looking for an algorithm which finds the shortest distance between a specified point and a known path connected by x/y-coordinates, so that I can kill all redundant points/nodes. A link or keyword for this algorithm would help me a lot! thanks for reading For better understanding: Are you wanting to calculate this in order to say something like "if the point-to-path distance is zero, then remove the point"? If so, then there is probably an easier way to remove redundant nodes. Take the points three at a time (call them A , B , and C ). Calculate the angle

choose n most distant points in R

眉间皱痕 提交于 2019-12-06 01:14:45
问题 Given a set of xy coordinates, how can I choose n points such that those n points are most distant from each other? An inefficient method that probably wouldn't do too well with a big dataset would be the following (identify 20 points out of 1000 that are most distant): xy <- cbind(rnorm(1000),rnorm(1000)) n <- 20 bestavg <- 0 bestSet <- NA for (i in 1:1000){ subset <- xy[sample(1:nrow(xy),n),] avg <- mean(dist(subset)) if (avg > bestavg) { bestavg <- avg bestSet <- subset } } 回答1: This code,