distance

How to get straight distance between two location in android?

走远了吗. 提交于 2019-12-02 17:21:45
First read Question carefully ... I need straight distance , not by walking,car ,or etc. Take a look to this image which given below, Google provide us distance by car and driving. But I don't want it, I want straight distance between two location (latitude - longitude). Which is displayed as as RED LINE. NOTE : I don't want to put red line on Google map, just want the Distance in Units (mile,km,etc.) ANDROID double distance Location locationA = new Location(“point A”) locationA.setLatitude(latA); locationA.setLongitude(lngA); Location locationB = new Location(“point B”); locationB.setLatitude

Jensen-Shannon Divergence

核能气质少年 提交于 2019-12-02 16:50:07
I have another question that I was hoping someone could help me with. I'm using the Jensen-Shannon-Divergence to measure the similarity between two probability distributions. The similarity scores appear to be correct in the sense that they fall between 1 and 0 given that one uses the base 2 logarithm, with 0 meaning that the distributions are equal. However, I'm not sure whether there is in fact an error somewhere and was wondering whether someone might be able to say 'yes it's correct' or 'no, you did something wrong'. Here is the code: from numpy import zeros, array from math import sqrt,

Calculating number of points within a certain radius [duplicate]

帅比萌擦擦* 提交于 2019-12-02 16:06:11
问题 This question already has answers here : find locations within certain lat/lon distance in r (4 answers) Closed 3 years ago . Given a data frame with latitudes and longitudes I want to add a column that simply contains the count of other points (of the same data frame) that are within a certain radius e.g. within 10 km of that specific point. Example data: set.seed(1) radius<-10 lat<-runif(10,-90,90) long<-runif(10,-180,180) id<-1:10 dat<-cbind(id,lat,long) id lat long [1,] 1 -42.20844 -105

How to assign several names to lat-lon observations

≡放荡痞女 提交于 2019-12-02 14:44:46
问题 I have two dataframes: df1 contains observations with lat-lon coordinates; df2 has names with lat-lon coordinates. I want to create a new variable df1$names which has for each observation the names of df2 that are within a specified distance to that observation. Some sample data for df1 : df1 <- structure(list(lat = c(52.768, 53.155, 53.238, 53.253, 53.312, 53.21, 53.21, 53.109, 53.376, 53.317, 52.972, 53.337, 53.208, 53.278, 53.316, 53.288, 53.341, 52.945, 53.317, 53.249), lon = c(6.873, 6

Difference between scipy pairwise distance and X.X+Y.Y - X.Y^t

谁都会走 提交于 2019-12-02 13:11:46
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 4 years ago . Let's imagine we have data as d1 = np.random.uniform(low=0, high=2, size=(3,2)) d2 = np.random.uniform(low=3, high=5, size=(3,2)) X = np.vstack((d1,d2)) X array([[ 1.4930674 , 1.64890721], [ 0.40456265, 0.62262546], [ 0.86893397, 1.3590808 ], [ 4.04177045, 4.40938126], [ 3.01396153, 4.60005842], [ 3.2144552 , 4.65539323]]) I want to compare two methods for generating the

Calculating number of points within a certain radius [duplicate]

江枫思渺然 提交于 2019-12-02 12:10:15
This question already has an answer here: find locations within certain lat/lon distance in r 4 answers Given a data frame with latitudes and longitudes I want to add a column that simply contains the count of other points (of the same data frame) that are within a certain radius e.g. within 10 km of that specific point. Example data: set.seed(1) radius<-10 lat<-runif(10,-90,90) long<-runif(10,-180,180) id<-1:10 dat<-cbind(id,lat,long) id lat long [1,] 1 -42.20844 -105.8491530 [2,] 2 -23.01770 -116.4395691 [3,] 3 13.11361 67.3282248 [4,] 4 73.47740 -41.7226614 [5,] 5 -53.69725 97.1429112 [6,]

JavaFX distance between two circle and keep updating property

℡╲_俬逩灬. 提交于 2019-12-02 09:21:26
For assignment, I created 2 draggable circle and connect them with line with javaFX. I need add text which calculate distance between two circle (or length of line) and that text need to keep updating when I drag circles, but that's where I stuck Circle circle1 = new Circle(); circle1.setCenterX(40); circle1.setCenterY(40); circle1.setRadius(10); Circle circle2 = new Circle(); circle2.setCenterX(120); circle2.setCenterY(150); circle2.setRadius(10); Line line = new Line (); line.startXProperty().bind(circle1.centerXProperty()); line.startYProperty().bind(circle1.centerYProperty()); line

Finding closest point from other data frame

蹲街弑〆低调 提交于 2019-12-02 07:46:26
I have two data frames , one is with 0.8 million rows with x and Y coordinates, another data frame is of 70000 rows with X and Y coordinates. I want to know logic and code in R where I want to associate data point from frame 1 to closest point in data frame 2. Is there any standard package to do so ? I am running nested for loop. But this is very slow as it is getting iterated for 0.8 million * 70000 times which is very time consuming. Hugo I found a faster way to get the expected result using the data.table library: library(data.table) time0 <- Sys.time() Here is some random data: df1 <- data

Difference between scipy pairwise distance and X.X+Y.Y - X.Y^t

柔情痞子 提交于 2019-12-02 06:52:05
Let's imagine we have data as d1 = np.random.uniform(low=0, high=2, size=(3,2)) d2 = np.random.uniform(low=3, high=5, size=(3,2)) X = np.vstack((d1,d2)) X array([[ 1.4930674 , 1.64890721], [ 0.40456265, 0.62262546], [ 0.86893397, 1.3590808 ], [ 4.04177045, 4.40938126], [ 3.01396153, 4.60005842], [ 3.2144552 , 4.65539323]]) I want to compare two methods for generating the pairwise distances: assuming that X and Y are the same: (X-Y)^2 = X.X + Y.Y - 2*X.Y^t Here is the first method as it is used in scikit-learn for computing the pairwise distance, and later for kernel matrix. import numpy as np

Calculate distance between 2 lon lats but avoid going through a coastline in R

风流意气都作罢 提交于 2019-12-02 05:20:41
问题 I am trying to calculate the closest distance between locations in the ocean and points on land but not going through a coastline. Ultimately, I want to create a distance to land-features map. This map was created using rdist.earth and is a straight line distance. Therefore it is not always correct because it not taking into account the curvatures of the coastline. c<-matrix(coast_lonlat[,1], 332, 316, byrow=T) image(1:316, 1:332, t(c)) min_dist2_feature<-NULL for(q in 1:nrow(coast_lonlat)){