Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Spatial Data: finding the closest point to a geographical point. Populating a distance field in a table.

$
0
0
I am using SS2014 and T-SQL.I have two tables. Both have latitude and longitude. I added a field called [coordinates) of geography data type to both tables and populated both with geography coordinates using "geography::Point([Lat], [Lon], 4326)" method.Now I want to match all the coordinates in Table A with the closest coordinate in Table B. Table A has about 300 records. Table B has about 1,600 records. While performance is not a major concern, I still don't want to wait minutes for the query to assign the nearest point to each point in table A.I have found examples where one supplies 2 coordinates and out pops a distance, but I need to do this computation for more than one point ... I need to compute the nearest point for every point in Table A.Would anyone have a link to an example on the web that would demonstrate this?Thanks ahead of time for any help you can provide!

Viewing all articles
Browse latest Browse all 3145

Trending Articles