Finding distance between two points

2497
10
05-17-2017 10:26 PM
roshnibasu
New Contributor III

Hi,

I am trying to find distance between two points using the following API.

http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?token=[mytoken]&...  

I'm getting below error :

{"error":{"code":400,"message":"Unable to complete operation.","details":["The input points are not all located within a single region."]}}

Please let me know how to resolve this.

0 Kudos
10 Replies
RandyBurton
MVP Alum

I believe your longitude and latitude pairs are in the ocean and not in North America.  Also longitude should be negative for NA.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I believe both sets of coordinates are in Japan, which would be positive longitude as specified.  Only 1 pair in Japan.

0 Kudos
RandyBurton
MVP Alum

I was considering that possibility.  I thought one might be Japan and the other Poland.  If so, this would be between Europe and Japan (and thus between 2 regions).  I think the NAServer is just for the North America region.

I believe this service is looking for a driving route between locations.  If a straight line distance is desired, using a great circle or Dan Patterson‌'s Vincenty calculator would be an easier solution.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You are right, I mistyped one of the coordinate pairs.  I agree, one is in Japan and the other Poland.

The NAServer doesn't mean North America, although the acronym does line up, I think it is "network analyst" since that is the server that does routing.

Realizing that one point is in Japan and the other Poland, the error message makes a bit more sense.  The routing is setup by regions, and there are certain regions that cannot be routed between.  For example, if you try to route between a random point in the middle of North America and a random point in South America, you won't be able to route between them.

RandyBurton
MVP Alum

"Network Analyst" makes sense in the URL path.  Perhaps our comments will also make sense to the OP.

0 Kudos
roshnibasu
New Contributor III

Hi Randy Burton and Joshua,

Thanks for your reply. So to calculate only distance does not ESRI provide any direct API?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

When you say distance, are you thinking/referring to "as a crow flies" or straight line?  Since you are using the World Route service, I think commentors assumed you were interested in travel or routed distance.

0 Kudos
roshnibasu
New Contributor III

Hi Joshua,

Thanks. Yes I actually want a straight line distance between two latlons.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

As Randy Burton‌ points out, use the Geometry Service and not Network Service.  Here is an example URL using the Geometry Service and your coordinates:

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer/distanc... 

0 Kudos