Select to view content in your preferred language

How to calculate Automatically Distances to one fixed point

610
1
02-28-2012 06:41 AM
ErmannoAffuso
New Contributor
I need to calculate the distances of 4500 housing units to a Park.

I have found this post http://forums.esri.com/Thread.asp?c=93&f=982&t=86666 (that is now closed) and I could edit the table of attribute of my shape file,
adidng a new field and using the field calculator with this code suggested by Olivier

In the shapefile, use the field calculator and paste the following pre-logic VBScript code (advanced)
-In the code, change the X and Y constants to the coordinates of the park
-Type 'Distance' in the 'FieldYouCalculate =' text box.

Const X As Double = 100000
Const Y As Double = 50000
Dim Distance As Double
Dim pPoint As IPoint
Set pPoint = New esriGeometry.Point
pPoint.PutCoords X, Y
Dim pProxOp As IProximityOperator
Set pProxOp = pPoint
Distance = pProxOp.ReturnDistance([Shape])

This procedure create the Field DIST2PARK (this is the way I named the new field)  in circa 30 seconds.

The only issue is that the distances calculated are not correct because I get a large number. I have tried as Constant parks X and Y's coordinates both in decimal degrees and meters. What is funny is that If I select the point related to the park and I check the correspondent cell in DIST2PARK this should be zero instead it has a large number.

Any idea and suggestion would be greatly appreciated. I am newbie to GIS.

Thanks
Tags (2)
0 Kudos
1 Reply
JoeBorgione
MVP Emeritus
Can the near command work for your?
That should just about do it....
0 Kudos