0

I have a large amount of data associated with latitude/longitude in a database (currently housed in MS SQL Server).

For the data, I would like to use SQL to calculate the distance from a user derived lat long and then use this distance in an inverse distance weighting (IDW) algorithm. I want to do this in SQL rather than inside of a GIS because the data is quite honestly large and complex and I have a tendency to not rely on ArcGIS to do these calculations.

I was wondering if there are SQL implementations of IDW algorithm out there that some could share.

As stated in the link above, IDW is NOT a distance calculator rather the IDW algorithm is an INTERPOLATION function which uses distance as an input. Please remove the duplication status.

user918967
  • 2,049
  • 4
  • 28
  • 43
  • Someone out there might have a SQLCLR implementation; outside of that I'm not sure what you'll get. – Brian Driscoll Aug 13 '14 at 20:42
  • 1
    If this were a question like "i'm having x problem w/ this IDW implementation" then it would fit here nicely. Asking for a library however is off topic for SO. Stackexchange has a very nice [GIS](http://gis.stackexchange.com/) site however that may be closer to what you need. – crthompson Aug 13 '14 at 20:49
  • I do not believe I asked for a library - I asked for SQL code. Also,I specifically asked for a non-GIS solution. – user918967 Aug 13 '14 at 22:23
  • I don't know about IDW. Are you asking for an algorithm that calculates the **nearest latitude and longitude pairs (proximity search)** based on the given latitude and longitude pair? If so, create a new question; I'll post the sql script. – Win Aug 13 '14 at 23:19
  • If you do not know about IDW why respond ? This question is not a distance calculation question and it is not a duplicate question. – user918967 Aug 13 '14 at 23:30
  • I am not sure why this was closed as a duplicate. @user918967 was not asking about haversine distances. Unfortunately I cannot answer the question but IDW is just a weighted average where the weights the weights are the inverse of the distances with a user-selected parameter "p". So `SUM(1/POWER(distance,p)*value)/SUM(1/POWER(distance,p) AS idw_weighted_value` will work – Scott Worland Jul 14 '20 at 16:14

0 Answers0