geographic-distance

How to get the nearest location entries from a database?

独自空忆成欢 提交于 2019-12-05 21:05:29
I store coordinates as latitude longitude pairs in my database. Now, I need to retrieve all the entries that are within a given radius from a given lat-long coordinate. For example, if given coordinates 48.796777, 2.371140 and distance of 20 kilometers, it would retrieve all the records within 20 kilometers from that point. If it provides any simplification or results in less CPU time, it's accurate enough to calculate the "straight" distance between the points, i.e. there's no need to factor in the curvature of the earth. How can this be achieved with Django? More specifically, how should the

SQL Geometry VS decimal(8,6) Lat, Long Performance

笑着哭i 提交于 2019-12-05 15:36:25
I was looking into performance of selecting closest points within certain proximity to given coordinate. Options are to ether use two decimal(8,6) - lat, long columns or single geography column and work with that. I am only interested which is faster? Matas Vaitkevicius TL;DR Geography is ~10 times faster. Ok so I have set up test: Couple of tables one with id,lat,long (int, decimal(8,6),decimal(8,6)) other with id,coord (int, geography) . Then insert 47k of random data. For indexing first table I used nonclustered Ascending index on lat,long with fill factor of 95. for second one GRIDS =

Fuzzy matching of coordinates

本小妞迷上赌 提交于 2019-12-05 07:18:42
问题 I have two datasets, one of them containing the coordinates of people's addresses ( addresses ), and the other one containing the coordinates of rainfall in certain locations ( rain ). The coordinates are standard lat and lon. I would like to merge these two sets together, by matching each address to the nearest rainfall location, using the spherical distance between two coordinates to determine the "nearest". The naive way is to compute all pairwise distances between each address and each

Measuring geographic distance with scipy

ⅰ亾dé卋堺 提交于 2019-12-04 14:14:27
I fail to use the outcome of scipy 's pdist function. I am interested in the real geographic distance (preferred unit: km). Take the following coordinates: from scipy.spatial.distance import pdist coordinates = [ (42.057, -71.08), (39.132, -84.5155) ] distance = pdist(coordinates) print distance # [ 13.75021037] But what's the unit? Google says the distance between these two points is 1179 km. How do I get there from 13.75021037? Using the latest Python 3, this now gives a deprecation warning. I actually found this answer by @cffk much easier to understand: (pasting here for convenience) >>>

Distance of wgs point from a wgs defined line segment

我怕爱的太早我们不能终老 提交于 2019-12-03 20:40:45
I searched but I could not find a complete answer. In C# if at all possible. I need the shortest distance between a WGS point and a WGS point defined line segment on a sphere (Earth exactly). float DistanceInKilometres(PointF LineStartA, PointF LineEndB, PointF ThePoint) EDIT: Perhaps an illustration would help Please note that this is an ideal example. 'The point' could be anywhere on the surface of the sphere, the segment start-end, too. Obviously, I'm not looking for the distance through the sphere. Math isn't my stronger side, so I don't understand normalize or to cartesian . Maybe I

How to assign a name to lat-long observations based on shortest distance

女生的网名这么多〃 提交于 2019-12-02 17:25:00
问题 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$name which has for each observation the name of df2 that has the shortest 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.82, 6.81,

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

Get pitch, roll and yaw relative to geographic north on iOS?

非 Y 不嫁゛ 提交于 2019-12-01 09:18:33
I see that I can retrieve CMAttitude from a device and from it I can read 3 values which I need (pitch, roll and yaw). As I understand, this CMAttitude object is managed by CoreMotion which is a Sensor Fusion manager for calculating correct results from compass, gyro and accelerometer together (on Android it is SensorManager Class). So my questions are: Are those values (pitch, roll and yaw) relative to the magnetic north and gravity? If above is correct, how can I modify it to give me results relative to the geographic north? If a device (such as iPhone 3GS) doesn't have an gyroscope, do I

Drawing a Circle with a Radius of a Defined Distance in a Map

巧了我就是萌 提交于 2019-11-29 16:14:29
I am able to plot a map and caption a specific point: library(maps) map("state") text(-80.83,35.19,"Charlotte",cex=.6) I can also plot a circle centered around that point: symbols(-80.83,35.19,circles=2, add=TRUE) However, I would like to control the size of the circle. In particular, I want to draw a circle with a radius of 100 mile around multiple locations contained in a data.frame, matrix, or list. You can write a function to customize how you want the circle to look. For example: plotCircle <- function(x, y, r) { angles <- seq(0,2*pi,length.out=360) lines(r*cos(angles)+x,r*sin(angles)+y)

Calculating distance between two points using latitude longitude and altitude (elevation)

99封情书 提交于 2019-11-29 02:46:22
I'm trying to calculate distance between two points, using latitude longitude and altitude (elevation). I was using euklides formula in order to get my distance: D=√((Long1-Long2)²+(Lat1-Lat2)²+(Alt1-Alt2)²) My points are geographical coordinates and ofcourse altitude is my height above the sea. I only have lat and lng, I'm using GOOGLE API Elevation to get my altitude. I'm developing an application which calculates my traveled distance (on my skis). Every application which I have used, gets distance traveled with included altitude. Like #Endomondo or #Garmin I cannot get my distance in 2D