distance

Wrong distance calculation with MongoDB

北慕城南 提交于 2019-11-28 04:50:38
问题 I am executing the following raw query with MongoDB: qry = {"position" : SON([("$near", [52.497309,13.39385]), ("$maxDistance", distance/111.12 )])} locations = Locations.objects(__raw__=qry) The position in the database is set to [52.473266, 13.45494] . I get a result once I set the distance to 7.3 or higher, so it seems the two locations must at least be 7.3 kilometer away from each other. When I calculate the distance of those two geo locations with Google Maps (for example going by car)

Finding Cities within 'X' Kilometers (or Miles)

天大地大妈咪最大 提交于 2019-11-28 04:35:41
This may or may not be clear, leave me a comment if I am off base, or you need more information. Perhaps there is a solution out there already for what I want in PHP. I am looking for a function that will add or subtract a distance from a longitude OR latitude value. Reason: I have a database with all Latitudes and Longitudes in it and want to form a query to extract all cities within X kilometers (or miles). My query would look something like this... Select * From Cities Where (Longitude > X1 and Longitude < X2) And (Latitude > Y1 and Latitude < Y2) Where X1 = Longitude - (distance) Where X2

Android - How to get estimated drive time from one place to another?

不羁的心 提交于 2019-11-28 04:25:47
I need to find the estimate drive time from one place to another. I've got latitudes and longitudes for both places but I have no idea how to do that. Is there is any API for that. help thanks. yes you get the time and distance value as well as many like direction details in driving, walking etc mode. all you got from the google direction api service check our this links http://code.google.com/apis/maps/documentation/directions/ Yaqub Ahmad Location location1 = new Location(""); location1.setLatitude(lat); location1.setLongitude(long); Location location2 = new Location(""); location2

How to get Distance Kilometer in android?

浪子不回头ぞ 提交于 2019-11-28 03:53:08
问题 I am very new to Google maps I want calculate the distance between two places in android. For that I get the two places lat and lag positions for that I write the following code: private double getDistance(double lat1, double lat2, double lon1, double lon2) { double dLat = Math.toRadians(lat2 - lat1); double dLon = Math.toRadians(lon2 - lon1); double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2) * Math.sin

Making a Location object in Android with latitude and longitude values

倖福魔咒の 提交于 2019-11-28 03:43:55
I have a program in which latitude and longitude values of a location are stored in a database, which I download. I want to get the distance between these coordinates, and my current location. The Location class has a simple method to find the distance between two Location objects, so I figured I'd make a Location object with the coordinates, then call the method. Is there an easy way to do this? Also, if there's another reliable, fairly simple equation that won't clutter things too much, that would work too. Thanks. (android.location.Location) Androiderson Assuming that you already have a

Compute the pairwise distance in scipy with missing values

落爺英雄遲暮 提交于 2019-11-28 03:18:13
问题 I'm a bit stumped by how scipy.spatial.distance.pdist handles missing ( nan ) values. So just in case I messed up the dimensions of my matrix, let's get that out of the way. From the docs: The points are arranged as m n-dimensional row vectors in the matrix X. So let's generate three points in 10 dimensional space with missing values: numpy.random.seed(123456789) data = numpy.random.rand(3, 10) * 5 data[data < 1.0] = numpy.nan If I compute the Euclidean distance of these three observations:

Convert a dataframe to an object of class “dist” without actually calculating distances in R

╄→гoц情女王★ 提交于 2019-11-28 01:53:04
I have a dataframe with distances df<-data.frame(site.x=c("A","A","A","B","B","C"), site.y=c("B","C","D","C","D","D"),Distance=c(67,57,64,60,67,60)) I need to convert this to an object of class "dist" but I do not need to calculate a distance so therefore I cannon use the dist() function. Any advice? I had a similar problem not to long ago and solved it like this: n <- max(table(df$site.x)) + 1 # +1, so we have diagonal of res <- lapply(with(df, split(Distance, df$site.x)), function(x) c(rep(NA, n - length(x)), x)) res <- do.call("rbind", res) res <- rbind(res, rep(NA, n)) res <- as.dist(t(res

Mahalonobis distance in R, error: system is computationally singular

爷,独闯天下 提交于 2019-11-27 23:04:55
I'd like to calculate multivariate distance from a set of points to the centroid of those points. Mahalanobis distance seems to be suited for this. However, I get an error (see below). Can anyone tell me why I am getting this error, and if there is a way to work around it? If you download the coordinate data and the associated environmental data , you can run the following code. require(maptools) occ <- readShapeSpatial('occurrences.shp') load('envDat.Rdata') #standardize the data to scale the variables dat <- as.matrix(scale(dat)) centroid <- dat[1547,] #let's assume this is the centroid in

Coordinates of the closest points of two geometries in Shapely

落花浮王杯 提交于 2019-11-27 20:06:01
There is a polyline with a list of coordinates of the vertices = [(x1,y1), (x2,y2), (x3,y3),...] and a point(x,y). In Shapely, geometry1.distance(geometry2) returns the shortest distance between the two geometries. >>> from shapely.geometry import LineString, Point >>> line = LineString([(0, 0), (5, 7), (12, 6)]) # geometry2 >>> list(line.coords) [(0.0, 0.0), (5.0, 7.0), (12.0, 6.0)] >>> p = Point(4,8) # geometry1 >>> list(p.coords) [(4.0, 8.0)] >>> p.distance(line) 1.4142135623730951 But I also need to find the coordinate of the point on the line that is closest to the point(x,y). In the

iphone accelerometer speed and distance

六月ゝ 毕业季﹏ 提交于 2019-11-27 19:12:20
I want to find distance traveled and velocity from accelerometer events. Like iphone's gMeter application is doing. Any suggestion, by which value or formula I should use for that? Thanks in advance. You can use the acceleration values from the accelerometer to measure the velocity and distance. There is really good paper ( Implementing Positioning Algorithms Using Accelerometers ) which explains the errors you get from the accelerometer and the techniques to get the velocity and position from the acceleration values. Some pseudo code: velocity[i] = (acceleration[i] + acceleration[i-1])/2 *