<?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 Re: Geocode Hosted Table in AGOL with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1234463#M66159</link>
    <description>&lt;P&gt;When I published the hosted table to AGOL I did not set the geocode. I am trying to do that via the python script.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2022 13:21:13 GMT</pubDate>
    <dc:creator>DustinDavis</dc:creator>
    <dc:date>2022-11-23T13:21:13Z</dc:date>
    <item>
      <title>Geocode Hosted Table in AGOL with Python</title>
      <link>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1233345#M66123</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to develop a python script that calls data from an API and updates a pre-existing hosted table in AGOL. I have the script updating the table correctly. The issue I have is the data points are not geocoding even with lat/long provided by the API. I have tried to geocode it a few ways and converting it to a feature layer but haven't had much luck. Anyone have tips for geocoding the updated data in the hosted table? What specific geocode operation should I use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.geocoding import geocode_from_items
import requests, json
from arcgis import GIS

# Variables
username = ""                 # AGOL Username
password = ""                               # AGOL Password
itemID = ''         # AGOL Table Item ID
dataURL = 'API Key'

# Disable warnings
requests.packages.urllib3.disable_warnings()

# Connect to AGOL
print("Connecting to AGOL")
gis = GIS('https://www.arcgis.com', username, password)

# Get Table
print("Get Hosted Table")
fLayer = gis.content.get(itemID)
editTable = fLayer.tables[0]
# Truncate Table
print("Truncate table")
editTable.manager.truncate()

# Get Data
print("Retrieving Data")
r = requests.get(dataURL, verify=False)
response = json.loads(r.content)
data = response['results']

# Create Dictionary of attributes and update table
print("Updating hosted table")
for attr in data:
    addFeatures =  {
            "attributes" : {
                "id" : attr['id'],
                "latitude" : attr['latitude'],
                "longitude" : attr['longitude'],
                "location" : attr['location'],
                "description": attr['description'],
                "gategory": attr['category'],
                "direction": attr['direction'],
                "routeName": attr['routeName'],
                "roadStatus":attr['roadStatus'],
            }
        }

    # Update Table
    editTable.edit_features(adds=[addFeatures])

print("Updated")

locate_item = editTable
locate_item

fl_item = geocode_from_items(locate_item, output_type='Feature Layer',
                             output_name="locate_OHGOapi",
                             gis=gis)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 18:35:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1233345#M66123</guid>
      <dc:creator>DustinDavis</dc:creator>
      <dc:date>2022-11-18T18:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Geocode Hosted Table in AGOL with Python</title>
      <link>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1233736#M66148</link>
      <description>&lt;P&gt;Is your geocoder set to geocode lat/long, or X,Y, or is it an address locator?&amp;nbsp; You'll have to match your inputs (lat/long) to the appropriate geocoder that can accept lat/long as the input.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 14:08:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1233736#M66148</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-11-21T14:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Geocode Hosted Table in AGOL with Python</title>
      <link>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1234463#M66159</link>
      <description>&lt;P&gt;When I published the hosted table to AGOL I did not set the geocode. I am trying to do that via the python script.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 13:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1234463#M66159</guid>
      <dc:creator>DustinDavis</dc:creator>
      <dc:date>2022-11-23T13:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Geocode Hosted Table in AGOL with Python</title>
      <link>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1234499#M66160</link>
      <description>&lt;P&gt;Ah, I misread your intentions and the docs '&lt;SPAN class=""&gt;geocode_from_items&lt;/SPAN&gt; geocodes the entire file regardless of size.' ... 'data points'- are they different from the points you are getting from the API?&lt;/P&gt;&lt;P&gt;It looks like you turned the response data (editTable) from the API into the &lt;EM&gt;geocoder&lt;/EM&gt;, rather than geocoding the response from the API so fl_item is now a geocoder. I think what you need is .geocode, where you can set the geocoder you have in your gis that accepts x,y fields.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 14:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geocode-hosted-table-in-agol-with-python/m-p/1234499#M66160</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-11-23T14:47:14Z</dc:date>
    </item>
  </channel>
</rss>

