Quantcast
Channel: SQL Server Spatial forum
Viewing all articles
Browse latest Browse all 364

SQL spatial join and STDistance results do not match ArcMap Spatial Join - Closet Distance Output

$
0
0

  I have two spatial files one point and one polyline both are projected in the same (Albers - meters). I have completed a spatial join using ArcMap (Target file point - Join file - line, match option Closest, with a Distance field generated). I used SQL 2012 (see code below - both files with matching spatial projection). The  (using Cross Apply) joining of the point data (crash)  to the closest road is correct however I am unable to get the two methods to reconcile on the distance.  For example in ArcMap the distance computed (and  I verified using the ruler tool) is 434 meters, while the same point join for the SQL code is 199 meters.  Any suggestions on how to reconcile these two methods is helpful.  This is my fledging effort to do more spatial work in SQL and move away from ESRI.  Thank you.

SELECT

AARD_TEST.OBJECTID,PR,SEGL,NFCOID_1,pt.OBJECTID,pt.Distance,pt.Shape,pt.CRASH_ID


FROM[GM].[dbo].[AARD_TEST]


  

CROSSAPPLY(


       

SELECTTOP1AWASH.OBJECTID,AWASH.SHAPE.STDistance(AARD_TEST.Shape)Distance,AWASH.Shape,AWASH.CRASH_ID


       

FROMAWASH

       

WHEREAWASH.Shapeisnotnull

       

ORDERBYAWASH.Shape.STDistance(AARD_TEST.SHAPE)

       

)pt;


Viewing all articles
Browse latest Browse all 364

Trending Articles