<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Trouble arcgis.geocoding module in ArcGIS Location Service Questions</title>
    <link>https://community.esri.com/t5/arcgis-location-service-questions/trouble-arcgis-geocoding-module/m-p/1394402#M26</link>
    <description>&lt;P&gt;I created a Python script that consumes a service from a locator and a feature service. When I enter an address into the tool, it retrieves all the suggestions and adds them to the feature service with the address and geometry. I generate the tool, and it works fine for me locally; I run the tool, it prompts me for the parameter, and it edits the feature service. The problem I have is when I try to publish it. I can publish it normally, but when I try to use the service, the role that the suggest takes (arcgis.geocoding module) returns something different from when I run it locally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;address = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;# Conectarse al portal de ArcGIS&lt;BR /&gt;gis = GIS("portal", "user","pass")&lt;/P&gt;&lt;P&gt;# URL del servicio de geocodificación&lt;BR /&gt;url_servicio = " "&lt;BR /&gt;#URL del feature service&lt;BR /&gt;url_feature_service = " "&lt;/P&gt;&lt;P&gt;portal_item = gis.content.get(" ")&lt;BR /&gt;ports_layer = portal_item.layers[0]&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("Conectándose al locator...")&lt;BR /&gt;#Conectar al locator&lt;BR /&gt;geocodificador = Geocoder(url_servicio, gis)&lt;/P&gt;&lt;P&gt;def add_features(direccion):&lt;BR /&gt;# Obtener sugerencias de geocodificación para la dirección&lt;BR /&gt;arcpy.AddMessage("Obteniendo sugerencias de geocodificación para la dirección...")&lt;BR /&gt;sugerencias = suggest(direccion, geocoder=geocodificador)&lt;BR /&gt;arcpy.AddMessage("Creando puntos en el feature layer...")&lt;BR /&gt;# Crear puntos en el feature layer con las coordenadas de las ubicaciones sugeridas&lt;BR /&gt;for sugerencia in sugerencias['suggestions']:&lt;BR /&gt;direccion_sugerida = sugerencia['text']&lt;BR /&gt;ubicacion = geocode(direccion_sugerida, geocoder=geocodificador, out_sr=4326)[0]['location']&lt;BR /&gt;&lt;BR /&gt;new_feature = {"attributes":&lt;BR /&gt;{"direccion": direccion_sugerida},&lt;BR /&gt;"geometry": ubicacion}&lt;BR /&gt;# Agregar el nuevo registro al feature layer&lt;BR /&gt;ports_layer.edit_features(adds=[new_feature])&lt;BR /&gt;&lt;BR /&gt;arcpy.AddMessage("Ejecutando el geoproceso...")&lt;BR /&gt;add_features(address)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I run it locally&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;{'suggestions': [{'text': 'CL 2B 18 27, CALI, VALLE DEL CAUCA, COL', 'magicKey': 'U3ViU291cmNlTmFtZT1Mb2NhdG9yR2RPRXN0cnVjdHVyYWRhfExvY2F0b3JDb21wdWVzdG9DYXVjYVZhbGxlVjEjbGJzPTE0OjE3NTAyMSNsbmc9MSNsb2M9MSNwbD0xNDY5NyN0cD0wI3R2PTY1YTI5NTk1', 'isCollection': False}, {'text': 'CL 2B 18 28, CALI, VALLE DEL CAUCA, COL', 'magicKey': 'U3ViU291cmNlTmFtZT1Mb2NhdG9yR2RPRXN0cnVjdHVyYWRhfExvY2F0b3JDb21wdWVzdG9DYXVjYVZhbGxlVjEjbGJzPTE0OjE3NTAyMiNsbmc9MSNsb2M9MSNwbD0yMDc2MDcjdHA9MCN0dj02NWEyOTU5NQ==', 'isCollection': False}, {'text': 'CL 2B 18 29, CALI, VALLE DEL CAUCA, COL', 'magicKey':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;When I run it as service on portal&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;esriJobMessageTypeInformative: {'currentVersion': 11.2, 'serviceDescription': '', 'addressFields': [{'name': 'Address', 'type': 'esriFieldTypeString', 'alias': 'Address or Place', 'required': False, 'length': 100, 'localizedNames': {'ar': 'العنوان أو المكان', 'ar-il': 'العنوان أو المكان', 'be': 'адрас', 'bg': 'Адрес или населено място', 'bs': 'Adresa ili mjesto', 'ca': 'Adreça o lloc', 'ca-es': 'Adreça', 'cs': 'Adresa nebo místo', 'cs-cz': 'Adresa nebo místo', 'cy': 'Cyfeiriad', 'cy-es': 'Cyfeiriad', 'cy-gb': 'Cyfeiriad', 'da': 'Adresse eller sted', 'de': 'Adresse oder Ort', 'de-at': 'Adresse oder Ort', 'de-be': 'Adresse oder Ort', 'de-ch': 'Adresse oder Ort', 'de-de': 'Adresse oder Ort', 'el': 'Διεύθυνση ή μέρος', 'en':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Since there are no "suggestions" the script fails:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in add_features for sugerencia in sugerencias['suggestions']: KeyError: 'suggestions'&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Mar 2024 22:10:19 GMT</pubDate>
    <dc:creator>Sergio_Velasquez</dc:creator>
    <dc:date>2024-03-11T22:10:19Z</dc:date>
    <item>
      <title>Trouble arcgis.geocoding module</title>
      <link>https://community.esri.com/t5/arcgis-location-service-questions/trouble-arcgis-geocoding-module/m-p/1394402#M26</link>
      <description>&lt;P&gt;I created a Python script that consumes a service from a locator and a feature service. When I enter an address into the tool, it retrieves all the suggestions and adds them to the feature service with the address and geometry. I generate the tool, and it works fine for me locally; I run the tool, it prompts me for the parameter, and it edits the feature service. The problem I have is when I try to publish it. I can publish it normally, but when I try to use the service, the role that the suggest takes (arcgis.geocoding module) returns something different from when I run it locally.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;address = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;# Conectarse al portal de ArcGIS&lt;BR /&gt;gis = GIS("portal", "user","pass")&lt;/P&gt;&lt;P&gt;# URL del servicio de geocodificación&lt;BR /&gt;url_servicio = " "&lt;BR /&gt;#URL del feature service&lt;BR /&gt;url_feature_service = " "&lt;/P&gt;&lt;P&gt;portal_item = gis.content.get(" ")&lt;BR /&gt;ports_layer = portal_item.layers[0]&lt;/P&gt;&lt;P&gt;arcpy.AddMessage("Conectándose al locator...")&lt;BR /&gt;#Conectar al locator&lt;BR /&gt;geocodificador = Geocoder(url_servicio, gis)&lt;/P&gt;&lt;P&gt;def add_features(direccion):&lt;BR /&gt;# Obtener sugerencias de geocodificación para la dirección&lt;BR /&gt;arcpy.AddMessage("Obteniendo sugerencias de geocodificación para la dirección...")&lt;BR /&gt;sugerencias = suggest(direccion, geocoder=geocodificador)&lt;BR /&gt;arcpy.AddMessage("Creando puntos en el feature layer...")&lt;BR /&gt;# Crear puntos en el feature layer con las coordenadas de las ubicaciones sugeridas&lt;BR /&gt;for sugerencia in sugerencias['suggestions']:&lt;BR /&gt;direccion_sugerida = sugerencia['text']&lt;BR /&gt;ubicacion = geocode(direccion_sugerida, geocoder=geocodificador, out_sr=4326)[0]['location']&lt;BR /&gt;&lt;BR /&gt;new_feature = {"attributes":&lt;BR /&gt;{"direccion": direccion_sugerida},&lt;BR /&gt;"geometry": ubicacion}&lt;BR /&gt;# Agregar el nuevo registro al feature layer&lt;BR /&gt;ports_layer.edit_features(adds=[new_feature])&lt;BR /&gt;&lt;BR /&gt;arcpy.AddMessage("Ejecutando el geoproceso...")&lt;BR /&gt;add_features(address)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I run it locally&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;{'suggestions': [{'text': 'CL 2B 18 27, CALI, VALLE DEL CAUCA, COL', 'magicKey': 'U3ViU291cmNlTmFtZT1Mb2NhdG9yR2RPRXN0cnVjdHVyYWRhfExvY2F0b3JDb21wdWVzdG9DYXVjYVZhbGxlVjEjbGJzPTE0OjE3NTAyMSNsbmc9MSNsb2M9MSNwbD0xNDY5NyN0cD0wI3R2PTY1YTI5NTk1', 'isCollection': False}, {'text': 'CL 2B 18 28, CALI, VALLE DEL CAUCA, COL', 'magicKey': 'U3ViU291cmNlTmFtZT1Mb2NhdG9yR2RPRXN0cnVjdHVyYWRhfExvY2F0b3JDb21wdWVzdG9DYXVjYVZhbGxlVjEjbGJzPTE0OjE3NTAyMiNsbmc9MSNsb2M9MSNwbD0yMDc2MDcjdHA9MCN0dj02NWEyOTU5NQ==', 'isCollection': False}, {'text': 'CL 2B 18 29, CALI, VALLE DEL CAUCA, COL', 'magicKey':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;When I run it as service on portal&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;esriJobMessageTypeInformative: {'currentVersion': 11.2, 'serviceDescription': '', 'addressFields': [{'name': 'Address', 'type': 'esriFieldTypeString', 'alias': 'Address or Place', 'required': False, 'length': 100, 'localizedNames': {'ar': 'العنوان أو المكان', 'ar-il': 'العنوان أو المكان', 'be': 'адрас', 'bg': 'Адрес или населено място', 'bs': 'Adresa ili mjesto', 'ca': 'Adreça o lloc', 'ca-es': 'Adreça', 'cs': 'Adresa nebo místo', 'cs-cz': 'Adresa nebo místo', 'cy': 'Cyfeiriad', 'cy-es': 'Cyfeiriad', 'cy-gb': 'Cyfeiriad', 'da': 'Adresse eller sted', 'de': 'Adresse oder Ort', 'de-at': 'Adresse oder Ort', 'de-be': 'Adresse oder Ort', 'de-ch': 'Adresse oder Ort', 'de-de': 'Adresse oder Ort', 'el': 'Διεύθυνση ή μέρος', 'en':&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;Since there are no "suggestions" the script fails:&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in add_features for sugerencia in sugerencias['suggestions']: KeyError: 'suggestions'&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2024 22:10:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-location-service-questions/trouble-arcgis-geocoding-module/m-p/1394402#M26</guid>
      <dc:creator>Sergio_Velasquez</dc:creator>
      <dc:date>2024-03-11T22:10:19Z</dc:date>
    </item>
  </channel>
</rss>

