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
Best Answer
Based on the documentation found here https://developers.arcgis.com/python/guide/reverse-geocoding/,
reverse the order of the location. Either:
m_location = reverse_geocode([location[1], location[0]])
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.