distance

Distance between two lat,lon points

送分小仙女□ 提交于 2019-12-07 02:05:23
问题 Is it ok to compare distances in a classic way (distance between 2 points: d = sqrt(pow(lat2-lat1, 2) + pow(lon2-lon1, 2)) ) using the latitude and longitude returned from google apis without any transformation to meters or sth? I need it just for a comparison to find the closest point from a series of points to a reference point. For example: Lets say we have two (lat,lon) points: (40.2535425,22.88245345) and (40.2565795,22.8884539) and we want to find witch is closest to (40.2335425,22

Google maps distance approximation

谁都会走 提交于 2019-12-07 01:40:29
问题 I've started to create a website where it's users are effectively tracked (they know they are being tracked). Users will walk a particular route (around Manchester, UK. to be more precise) of which there are 10 checkpoints. A checkpoint is a static position on the map. Using the Google Maps API I know that I can plot a position on a map i.e. a checkpoint. I am also storing the time at which a user reaches said checkpoint. Taking the distance between checkpoints I am then able to calculate

Boids in python; calculating distance between two boids

♀尐吖头ヾ 提交于 2019-12-07 00:24:25
I'm trying to program the behaviour of birds in flight with boids in Python. I haven't found much yet but currently i'm stuck on the function defining the distance between two boids. It has to be calculated with the formula (a,b) = sqrt( (a_x - b_x)^2 + (a_y - b_y)^2) ) where a and b are the two vectors between which i have to calcualte the distance, a_x and b_x are the x-components of the vectors and a_y and b_y are the y-components. I get an error about the indices in the formula. I've tried solving in in a number of ways but i just can't figure out how to do it... Here is what i've got so

How to create a Large Distance Matrix?

孤街醉人 提交于 2019-12-06 16:07:33
How to allocate a huge distance matrix in an appropriate way to avoid " allocation is unable " error. Imagine you have a 100.000 points randomly spreaded over some space. How can one cleverly create a matrix or "dist"-object, which represents the the half of DistMatrix. Maybe it should be another object, which will be able efficiently allocate the large number of distances. You can get the polygonial object from the following link: https://www.dropbox.com/sh/65c3rke0gi4d8pb/LAKJWhwm-l # Load required packages library(sp) library(maptools) library(maps) # Load the polygonal object x <-

Finding nearest neighbor between 2 sets of dated points

↘锁芯ラ 提交于 2019-12-06 15:46:48
I have 2 sets of points, set1 and set2 . Both sets of points have a data associated with the point. Points in set1 are "ephemeral", and only exist on the given date. Points in set2 are "permanent", are constructed at a given date, and then exist forever after that date. set.seed(1) dates <- seq(as.Date('2011-01-01'),as.Date('2011-12-31'),by='days') set1 <- data.frame(lat=40+runif(10000), lon=-70+runif(10000),date=sample(dates,10000,replace=TRUE)) set2 <- data.frame(lat=40+runif(100), lon=-70+runif(100),date=sample(dates,100,replace=TRUE)) Here's my problem: For each point in set1 (ephemeral)

calculate distance between 2 coordinates iphone - best practice

冷暖自知 提交于 2019-12-06 15:25:55
问题 I'm finishing an App in wish i need to show the user the distance between him and about 500 coordinates. using the CLLocation method to calculate it, works well, but it takes about 1 minute in iPhone 4 to finish calculations for each location. What is the best way to do it? Using span? Any other faster way? Thanks all, rui 回答1: I think Sahgal is right, here is some code, perhaps it will help you. +(CGFloat)calculateDistanceBetweenSource:(CLLocationCoordinate2D)firstCoords andDestination:

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

旧街凉风 提交于 2019-12-06 13:38:29
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? 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=1000000,cellnumbers=TRUE) 来源: https://stackoverflow.com/questions/13996256/get-cell-number-within-a-distance-of

Color Remapping - Matching target palette using a 3D grid?

不羁的心 提交于 2019-12-06 13:24:15
Let's say I have color 'FOO', and it is stored in RGB format. I need to recolor 'FOO' so it matches the closest color in a list of colors. Doing this on the fly, couldn't I view the RGB values from each color as points on a 3D grid (r=x, g=y, b=z) and compute the distance between point 'FOO' vs the points from each color in the list? The closest point to 'FOO' would be the replacement color? In theory, yes. In reality, computing the closest color is non-trivial if you want to do it well. Just for example, people's eyes are much more sensitive to changes in brightness than color shifts,

Distance between two rectangles

杀马特。学长 韩版系。学妹 提交于 2019-12-06 13:13:40
How can I find the distance between two rectangles? Intersects should return 0 in distance. Here's a quick function for calculating distance between two CGRects represented by a CGSize: CGSize CGSizeDistanceBetweenRects(CGRect rect1, CGRect rect2) { if (CGRectIntersectsRect(rect1, rect2)) { return CGSizeMake(0, 0); } CGRect mostLeft = rect1.origin.x < rect2.origin.x ? rect1 : rect2; CGRect mostRight = rect2.origin.x < rect1.origin.x ? rect1 : rect2; CGFloat xDifference = mostLeft.origin.x == mostRight.origin.x ? 0 : mostRight.origin.x - (mostLeft.origin.x + mostLeft.size.width); xDifference =

Android: how to find total distance covered using GPS when continuously moving?

与世无争的帅哥 提交于 2019-12-06 08:34:06
问题 This is my code. Please tell me y it is not able to calculate the distance.. In this code res is a long variable which is supposed to store the total distance covered. This code is supposed to calculate distance based on GPS as soon as there is a change in the latitude and longitude.. String serviceString = Context.LOCATION_SERVICE; LocationManager locationManager; locationManager= (LocationManager)getSystemService(serviceString); String provider = LocationManager.GPS_PROVIDER; final Location