Select to view content in your preferred language

What is distance in PointDistance_analysis

1139
5
Jump to solution
02-22-2011 12:14 PM
BarryDurand
Emerging Contributor
My apologies if this is not in the right forum or if it is a very basic question but I have been working on this all afternoon and it is driving me crazy. What would be causing the following script to give me incorrect results:

import arcpy
arcpy.env.workspace = "C:\Documents and Settings\bpdurand\My Documents\ArcGIS\Default.gdb"
arcpy.PointDistance_analysis("address","hospital","howfar")

I thought that it would calculate the distance in miles between the points in the address and the point for the hospital in miles. However it is giving me answers such as 0.104308 and 0.037853. I have changed the display units in properties->general for the layer (it was not set to miles) to miles but it did not help.

Any hints would be appreacited.

What is really frustrating is that I can easily do what I want interactively but I can not do it in batch.

Thank you!
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus
depending upon your definition of miles and feet
2 miles = 10560 feet
2 miles = 3218 meters
so I wild guess is that you projected to a projection which uses meters and not feet.  Check to be sure

View solution in original post

0 Kudos
5 Replies
DanPatterson_Retired
MVP Emeritus
Project your data.  I suspect that they are in decimal degrees (aka a geographic coordinate system GCS....)
0 Kudos
BarryDurand
Emerging Contributor
Thank you.  That made a difference but the numbers of totally off in the other direction. It should be about 2 miles but not it is showing 3538.42664.  I will continue to play with it because you were right on the money that it was GCS.

Again, I find it really frustrating that it works just fine interactively but not in batch.
0 Kudos
DanPatterson_Retired
MVP Emeritus
depending upon your definition of miles and feet
2 miles = 10560 feet
2 miles = 3218 meters
so I wild guess is that you projected to a projection which uses meters and not feet.  Check to be sure
0 Kudos
BarryDurand
Emerging Contributor
Dan!

You are an amazing genious!  I thought that I had checked that but obviously I was wrong.
I am trying to get it into miles but at least now I know that the data is right!

Thank you!

Barry
0 Kudos
BarryDurand
Emerging Contributor
I even got it to change to miles as I wanted it to.  When transforming the map from one coordinate system to other, after all is done and you switch to the new coordinate system click on Modify in the Coordinate System Tab in Properties. There you can switch it to miles or whatever.

Again, Thanks to every one who helped.

I have written up a step by step process of how to find the distance between two points.  If anyone needs it, just contact me.

Barry Durand
UA School of Social Work
bpdurand@sw.ua.edu
0 Kudos