distance

get cell number within a distance of one point (raster)

落花浮王杯 提交于 2019-12-07 20:53:51
问题 I need to get the cell numbers within a distance (e.g., 10 km) of one point using R, but I didn't figure out how to handle it for the raster data. library(raster) r <- raster(ncols=10, nrows=10) cellFromXY(r, c(2,2)) # get the cell number of one point How to get the cell numbers within a distance of one point? 回答1: Use extract with the buffer option and cellnumbers=TRUE r <- raster(ncols=100, nrows=100) r[]<-runif(ncell(r)) xy <- cbind(-50, seq(-80, 80, by=20)) extract(r, xy[1:3,], buffer

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

依然范特西╮ 提交于 2019-12-07 16:04:08
问题 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

Calculate the distance between two points in iphone

岁酱吖の 提交于 2019-12-07 14:08:22
问题 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:

How to find closest (nearest) value within a vector to another vector?

点点圈 提交于 2019-12-07 13:23:46
问题 I have two equal sized vectors, e.g. A=[2.29 2.56 2.77 2.90 2.05] and B=[2.34 2.62 2.67 2.44 2.52]. I am interested to find closest values (almost equal) in two same size vectors A & B, i.e. out of all elements in A, which value is closest to any element of B? The solution should be extendable to any number of (equal size) vectors also. Means able to find closest values with a group of same sized vectors A,B &C. The two resulting values can be from either of two vectors. For clarity, i am not

Shortest distance between point and path

杀马特。学长 韩版系。学妹 提交于 2019-12-07 12:44:49
问题 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: 回答1: 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

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

有些话、适合烂在心里 提交于 2019-12-07 08:15:29
问题 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

Compute distance in Cartesian Coordinate System in Mathematica

北城以北 提交于 2019-12-07 06:04:18
问题 Analyzing Eye-movements on a screen, I set my origin to the bottom left corner of it (Hard to modify at that point). Trying to compute distance between some points and the center of the screen I use the simple formula displayed below. Problem is that using this in conditional statement, it gets ugly. Sqrt[ ( (fixationX - centerX)^2 + (fixationY - centerY)^2 ) ] Is there a way to customize Norm to compute distance between points and not between a point and the origin ? Or in my case, set the

Android: best method to calculate distance between two locations

我们两清 提交于 2019-12-07 05:18:13
问题 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

How to calculate Euclidean length of a matrix without loops?

谁说胖子不能爱 提交于 2019-12-07 04:53:11
问题 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

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

爱⌒轻易说出口 提交于 2019-12-07 03:35:46
问题 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 =