<jupyter_start><jupyter_text>An introduction to geocodingGeocoders are tools to which you pass in an address / place of interest and it gives back the coordinates of that place.The **`arcgis.geocoding`** module provides types and functions for geocoding, batch geocoding and reverse geocoding.<jupyter_code>from arcgis.gis import GIS
from arcgis import geocoding
from getpass import getpass
password = getpass()
gis = GIS("http://www.arcgis.com", "arcgis_python", password)<jupyter_output><empty_output><jupyter_text>Geocoding addressesAll geocoding operations are handled by `geocode()` function. It can geocode  1. single line address 2. multi field address 3. points of interest 4. administrative place names 5. postal codes<jupyter_code>results = geocoding.geocode('San Diego, CA')
results
len(results)
results[0]
map1 = gis.map('San Diego, CA')
map1
map1.draw(results[0]['location'])<jupyter_output><empty_output><jupyter_text>Geocode single line addresses<jupyter_code>r2 = geocoding.geocode('San Diego Convention center')
len(r2)
[str(r['score']) +"  :  "+ r['attributes']['Match_addr'] for r in r2]<jupyter_output><empty_output><jupyter_text>Geocode multi field address<jupyter_code>multi_field_address = { 
    "Address" : "111 Harbor Dr",
    "City" : "San Diego",
    "Region" : "CA",
    "Subregion":"San Diego",
    "Postal" : 92103,
    "Country":"USA"
    }
r_multi_fields = geocoding.geocode(multi_field_address)
len(r_multi_fields)<jupyter_output><empty_output><jupyter_text>Searching within an exentFind restaurants within walking distance of this training center (Hard Rock Hotel, Palm Springs)<jupyter_code># first create an extent.
conv_center = geocoding.geocode('San Diego Convention Center, California')[0]
map3 = gis.map('San Diego Convention Center', zoomlevel=17)
map3
restaurants = geocoding.geocode('grocery',search_extent=conv_center['extent'], 
                                max_locations=15)
len(restaurants)
map3.clear_graphics()
for shop in restaurants:
    popup = { 
    "title" : shop['attributes']['PlaceName'], 
    "content" : shop['attributes']['Place_addr']
    }
    map3.draw(shop['location'],popup)<jupyter_output><empty_output><jupyter_text>Batch geocoding<jupyter_code>addresses = ["380 New York St, Redlands, CA", 
             "1 World Way, Los Angeles, CA",
             "1200 Getty Center Drive, Los Angeles, CA", 
             "5905 Wilshire Boulevard, Los Angeles, CA",
             "100 Universal City Plaza, Universal City, CA 91608",
             "4800 Oak Grove Dr, Pasadena, CA 91109"]
results = geocoding.batch_geocode(addresses)
len(results)
map5 = gis.map('Los Angeles, CA')
map5
for address in results:
    map5.draw(address['location'])<jupyter_output><empty_output><jupyter_text>Reverse geocoding<jupyter_code>reverse_geocode_results = geocoding.reverse_geocode([2.2945, 48.8583])
reverse_geocode_results
map6 = gis.map('San Diego convention center, San Diego, CA', 16)
map6
def find_addr(map6, g):
    try:
        map6.draw(g)
        geocoded = geocoding.reverse_geocode(g)
        print(geocoded['address']['Match_addr'])
    except:
        print("Couldn't match address. Try another place...")
map6.on_click(find_addr)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1170807453416149, 'fraction_numerical': 0.024844720496894408, 'mean_word_length': 5.054511278195489, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '22622', 'license': 'Apache-2.0', 'n_tokens_mistral': 1116, 'n_tokens_neox': 1054, 'n_words': 263, 'path': 'talks/uc2017/ArcGIS Python API - Advanced Scripting/geocoding/introduction_geocoding.ipynb', 'repo_name': 'nitz21/arcpy', 'size': '3220'}