1

I am working on a Alexa skill where I get the user's location (Lat, Long) from the device. Since my skill only applies to a specific city (Boston, USA), I am using the ArcGIS reverse_geocode to determine if that Lat, Long is in Boston, but the input is in the XY format.

I wrote the following method:

from arcgis.gis import GIS
from arcgis.geocoding import reverse_geocode
from arcgis.geometry import from_geo_coordinate_string

gis = GIS()
location = [42.3937647, -71.1449038]
m_location = reverse_geocode(location)
print(m_location)

# Error:
# Cannot perform query. Invalid query parameters.
# Unable to find address for the specified location.

Therefore, I need to convert my lat,long to XY. I found the find_transformation function, but don't know how to use as inputs (the in_sr and out_sr, for instance).

I cannot use packages such as pyproj, because the team does not approve, and I'm positive that ArcGIS has a function for converting between coordinates

1

Based on the documentation found here https://developers.arcgis.com/python/guide/reverse-geocoding/,

Location parameter

The point from which to search for the closest address. The point can be represented as a simple list of coordinates ([x, y] or [longitude, latitude]) or as a JSON point object.

reverse the order of the location. Either:

  • m_location = reverse_geocode([location[1], location[0]])
  • or simply change location to have longitude listed first, like location = [-71..., 42...] (obscured for privacy reasons).

This will use the default spatial reference of WGS84, but can be overridden if needed. Your geocode is likely to be in WGS84.

  • Perfect! I had my location in Lat, Long, but the function takes Long, Lat – Bruno Cortez Aug 31 '19 at 21:05

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.