0

I'm drawing a bunch of carrier routes from the USPS API to an ArcGIS map. I need to only show the routes that are within a certain distance from a certain point. I have the latitude and longitude for the center point.

I thought the paths used by Polyline were made up of latitude and longitude sets multiplied by 100000, and I tried using them as such but that didn't work. The paths are generated from point sets that look like this: -9214713, 3256075. When divided by 100000 they look like longitude and latitude, but I guess they're not.

What are these coordinates used in the Path parameter of the Polyline class, and how can I convert them to lat and lng for the purpose of calculating distance?

  • 2
    Those coordinates look like they're in linear units (meters) rather than angular (degrees). My guess is they're in some sort of Mercator projection and you're going to need to project either them to the coordinate system of your point or vice versa. Check out this link for some info on that: developers.arcgis.com/javascript/latest/api-reference/… . – AHigh Mar 9 '17 at 21:42
  • Is there any metadata with the USPS API that describes the fields? When you say a certain distance from a certain point do you mean euclidean or driving distance? It's fairly hard to guess what that field could be just given a value - it could be just about anything. – Michael Stimson Mar 9 '17 at 22:17
  • I realize it's not a real clear question i was trying to avoid adding a bunch of irrelevant info. The USPS API is not public. I got a one page Word doc that explained the endpoints and little else. When I require assistance I have to email our representative at USPS at which point he shows up at my office a weeke later and tries to answer it, but he doesnt really know much so it's usually a waste of time. I just need distance as the crow flies but that isn't the question, I can do that on my own if I have the lat and long. I just need to figure out what I have and how to convert it to lat and – I wrestled a bear once. Mar 9 '17 at 22:44
  • You need to focus this question on the coordinates and spend less time on what you're doing with them. Either they're in ten-microdegree units or they're not. We have no way to help you until you identify the units of your data or provide enough details that we can. – Vince Mar 10 '17 at 1:04
  • Identify the units.. lol.. I'm asking what the sum of 2 and 2 are you're telling me to add two plus two and then ask again. Right, thank you for the help. Identifying the units was the only real problem. If I knew what they were I would not be asking. I think the first comment should be enough for me to figure the rest out on my own tomorrow. I'll post the answer when I figure it out. Thanks everyone. – I wrestled a bear once. Mar 10 '17 at 3:59
1

The type of coordinates can be determined by the spatial referece attribute. Specifically, MyPolyline.spatialReference._info determined that it was metric, mercator units as suggested by AHigh in the first comment.

Converting them to lat/lng was simple using webMercatorUtils.xyToLngLat(x, y).

See here: https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.webmercatorutils-amd.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.